tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zohar Amir" <>
Subject NPE in init()
Date Thu, 20 Oct 2005 11:37:43 GMT
I'm new here, so all the normal disclaimers...
I wrote a servlet and needed to read some configuration, so I overrode 
init(ServletConfig config). I forgot to invoke super(config) and then tried 
invoking getServletContext() and got a NPE. It took me some (a lot actually) 
time to figure out why...
My question is why can't a descriptive exception be thrown when invoking 
anything that presumes that config is set? I refer to GenericServlet, where 
a few methods rely on getServletConfig() to return a non-null value, and act 
on it. TMHO the return value should be checked and a descriptive exception 
be thrown ("servlet should be initialized" or whatever), instead of the NPE.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message