Topic: Servlets 2.4
Application Server: JBoss 4.0.2 / Tomcat 5.5.9
Exception:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.NullPointerException com.HelloWorldServlet.doGet(HelloWorldServlet.java:15) javax.servlet.http.HttpServlet.service(HttpServlet.java:697) javax.servlet.http.HttpServlet.service(HttpServlet.java:810) org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
Resolution:
The cause for this exception is the absence of an explicit call in the overloaded init() method that has the signature: public void init(ServletConfig config)
The first line of the method should be super.init(config) to remove this exception.
A better way to resolve this is to override the parameter-less init() method, the one that has the signature: public void init()
In this version of the init(), there is no need for the explicit super.init(config) call
No comments:
Post a Comment