IBM VAJ WTE environment
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:
Can anyone help me out ?
IllegalArgumentException in the throws clause.
javax.servlet.ServletException: PhotekServlet: (error) no pageSize parameter was specified
(Yes, I named it after you. )
The occurs when I access it with
but it disappears when I use
where "photek" is the servlet alias of PhotekServlet. It also works when you have an explicit servlet mapping.
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.
[ 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.