On Wed, 12 Dec 2001, Etienne Deleflie wrote:
> Date: Wed, 12 Dec 2001 15:11:21 +1100
> From: Etienne Deleflie <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: getInitParameter() throws an exception .....
>
> Hello all,
>
> I am using tomcat 4.0.1 (and jdk1.3.1)
>
> In my servlet, the getInitParameter() throws an NullPointerException
> ...(stack trace below)... ..... but where is the null pointer ?
>
> code is ............ String path = getInitParameter("properties");
>
> Is there something wrong with my declarations in the web.xml file ?
>
The most common cause for this is that you implement:
public void init(ServletConfig config) throws ServletException {
...
String value = config.getInitParameter("properties");
...
}
without calling super.init(config) inside the method body.
The best way to protect yourself from this mistake is to implement
public void init() throws ServletException {
...
String value = getServletConfig().getInitParameter("properties");
...
}
instead.
Craig McClanahan
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>