Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.lang.NullPointerException when calling getServletContext

843841Sep 29 2004 — edited May 20 2008
Hi 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.


Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 17 2008
Added on Sep 29 2004
6 comments
1,983 views