Quantcast
Channel: Active questions tagged servlets - Stack Overflow
Viewing all articles
Browse latest Browse all 675

java.lang.NullPointerException in FilterChain doFilter method

$
0
0

I have added a filter in web.xml deployment descriptor. But whenever a request is coming to the server, the filter throws a NullPointerException:

java.lang.NullPointerException org.apache.commons.beanutils.PropertyUtilsBean.getIndexedProperty(PropertyUtilsBean.java:427)org.apache.commons.beanutils.PropertyUtilsBean.getIndexedProperty(PropertyUtilsBean.java:340) org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:664) org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:715) org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:884) org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:811) org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:298) org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1252) org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482) org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525) javax.servlet.http.HttpServlet.service(HttpServlet.java:641) javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

Below given the code segment where the exception occures.

public void doFilter(ServletRequest request, ServletResponse response,                     FilterChain chain)     throws IOException, ServletException {    HttpServletRequest httpRequest = (HttpServletRequest) request;    HttpServletResponse httpResponse = (HttpServletResponse) response;    boolean isAjax = "XMLHttpRequest".equals(httpRequest.getHeader("x-requested-with"));    HttpSession httpSession = httpRequest.getSession(false);    if(isAjax){        if(isValidRequest(httpRequest, httpSession)){            chain.doFilter(request, response);        }else{            returnInvalidMessage(httpRequest, httpResponse);        }    }else{        chain.doFilter(request, response); /* Here is the exception occures */    }}

Exception occured in the below line

chain.doFilter(request, response);

Is anyone have an idea about this?


Viewing all articles
Browse latest Browse all 675

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>