tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zohar Amir" <david_fi...@hotmail.com>
Subject NPE in init()
Date Thu, 20 Oct 2005 11:37:43 GMT
Hello,
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.
Thanks,
Zohar. 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message