java.lang.NullPointerException when calling getServletContext
843841Sep 29 2004 — edited May 20 2008Hi All,
When calling getServletContext from my servlet, i'm getting the following exception to my web client:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
javax.servlet.GenericServlet.getServletContext(GenericServlet.java:159)
amdocs.checklist.UserPage.service(UserPage.java:126)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
amdocs.checklist.LoginFilter.doFilter(LoginFilter.java:65)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.27 logs.
My code is:
ServletContext sc = getServletContext();
RequestDispatcher rd = getServletContext().getRequestDispatcher("/Header");
rd.include(request, response);
It couldn't pass the call of getServletContext, Any idea why?
Thanks.