"Christopher K. St. John" wrote:
>
> Kevin Mukhar wrote:
> >
> > The servlet container does not send a response back
> > when it catches an exception.
> >
>
> The spec seems to indicate that the container _should_
> send a response back. Tomcat (3.?) sends back a 500
> "Internal Server Error" and gives a stack trace, which
> seems pretty reasonable, but 2.3PFD 9.8 describes
> setting up error pages.
>
> > You can still throw the exception up to the servlet
> > container if you want, but you should also send a
> > response back to the client which says that the request
> > could not be processed.
>
> So, if the container is supposed to send back an error
> response (9.8) when it gets an exception, what is supposed to
> happen if content has already been sent when the exception
> happens? What exactly does "take appropriate measures"
> mean in that case?
Well, that'll teach me to use the spec for all of my answer, not just
parts of my answer.
Based on this, my opinion is almost the same: for production, have the
servlet send a custom error response back to the client, but do NOT
throw the exception out of doPost or doGet. In my opinion it's not
helpful to the user to send a stack trace back to the client. For most
users, the stack trace means nothing, and is more confusing than
helpful. You should send some sort of custom response expecially if the
problem is fixable by the client, i.e. the user forgot to enter some
data, or the user entered bad data.
For development, its okay to send a stack trace back, because then the
user who sees it is usually a developer or a tester, and the stack trace
is useful in this situation.
On a project I worked, we did both. We sent back a custom error page,
and the servlet could append the stack trace to the error page. The
normal procedure was to send back just the error page. A simple config
change would add the stack trace. This made it easy to get debug
information after the app was deployed to the customer's site.
K Mukhar
___________________________________________________________________________
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