0

I have created a wrapper class to validate all the input parameters by assigning them into an array. I am getting request from Filter class. getParameterValues is not working which I am using to get the request parameters into an array.

        public class XSSRequestWrapper extends HttpServletRequestWrapper {  

            public XSSRequestWrapper(HttpServletRequest servletRequest) {
              super(servletRequest);       
            }

Following code works fine

             public String getParameter(String name) {
                // TODO Auto-generated method stub
                                    return super.getParameter(name);
             }  

Following doesn't work at all

            public String[] getParameterValues(String name) {
             // TODO Auto-generated method stub

                  return super.getParameterValues(name);
            }

Following is the filter.java

 //@WebFilter("/filter")
public class filter implements Filter {


    public filter() {
        // TODO Auto-generated constructor stub
    }


    public void destroy() {
        // TODO Auto-generated method stub
    }


    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
                    chain.doFilter(new XSSRequestWrapper((HttpServletRequest) request), response);


    }
    public void init(FilterConfig fConfig) throws ServletException {
        // TODO Auto-generated method stub
    }

}

  • instead of `String[]` shouldn't it be `char[]'? My Java is very rusty but I remember having a similar issue in my first year of uni. Please include error codes! – LeonH Apr 08 '16 at 07:29
  • Unfortunately there is no error or exception. It is just not getting called at all. – Vaibhav Shukla Apr 08 '16 at 07:32
  • If it's not getting called at all, then shouldn't you be including the code where you call these functions? So that we can see where the error currently lies? – LeonH Apr 08 '16 at 07:33
  • String[] getParameterValues(String parameter) is HttpServletRequestWrapper class method and so is getParameter(String parameter). One of them is working and the other is not. Both are inside the Wrapper class. – Vaibhav Shukla Apr 08 '16 at 07:37
  • Food for thought: http://stackoverflow.com/q/2658922 – BalusC Apr 08 '16 at 08:10

0 Answers0