What actually happens if your servlet throws an exception depends on the
server being used, but most of them will probably send an error message
to the user, perhaps with a stack traceback, which is a pretty ugly way
to deal with it. Unless such an exception is thrown in the init()
method, it shouldn't mess up other calls to the servlet -- but your
users are not going to be pleased with what they get in response.
Exceptions won't "damage" the server or JVM in any way -- they are a
normal part of the Java language. But, IMHO, *any* servlet that throws
*any* uncaught exception is broken, and should be fixed.
Craig McClanahan
Balogh Andras wrote:
> Hi, I have a strange question. How hard is to the server
> to handle Exceptions ?To be more precise here is an example:I have a
> form with 3 fields:name,telephone,address.I retrieve the parameters in
> the servlet with the usuallymethod
> req.getParameterValues("name")[0].Now if the servlet is called from
> the right form that everything is OK.But if someone removes the 'name'
> field from the form my servlet throws aNullPointerException wich is a
> normal behavior.So my question is: this exception will be a SHOCK to
> the server(or the JVM) or it will terminate the servlet as nothing
> were happen?Or another question: Too many exceptions will produce
> anabnormal behavior of the server(JVM) after a time ??I am asking
> this question becuase if the answer is NO (meening that Exceptions
> don't affect at allthe server or JVM) that i will drop the extra if
> conditions like:if(req.getParameterValues("name")!=null)
> name=req.getParameterValues("name")[0]. Waiting for Your
> answers. Thank you, Andras
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html