Context IBM VAJ WTE environment Problem I wrote a servlet and it is working fine. I then needed the servlet to read some parameters and to persist them to the application scope. The servlet compiled fine. But when the servlet is loaded, I get this error on my browser: Server caught unhandled exception from servlet [FooServlet]: null My init method looks something like this:
I think the problem is that if pageSize < 1 you will throw an IllegalArgumentException() at that point processing stops, the exception will not be caught by the "IllegalArgumentException" catch phrase, so the method signature of the init() method has to specify the IllegalArgumentException in the throws clause. Craig
Joined: Mar 19, 2002
But, I think it would be more correct if you changed the code to:
Hey guys, I've rewritten the init method to look like this, and it's working fine.
The changes made: * In the line marked 1, I made a call to the superclass's init method. I read that if you're going to override the init, this is something which needs to be done. Why ? I don't know. * I've dispensed with all the exceptions by rolling up the exceptions into one catch-all because that simplifies the code. Pho [ April 06, 2002: Message edited by: Pho Tek ]
In the line marked 1, I made a call to the superclass's init method. I read that if you're going to override the init, this is something which needs to be done. Why ? I don't know.
Simple, thats the only way to attach the configuration information to your servlet. If you don't do that you get mysterious null pointer exceptions later. Your problem with different behaviour when addressing the servlet different ways is related to the information in web.xml. If you don't use the web.xml alias, the servlet does not get init-params from web.xml. Bill