Tony LaPaso wrote:
Hi all,
I'm not sure if this falls more into JSP or servlet territory.
I have a JSP that includes a servlet via:
<jsp:include page="MyServlet"/>
Within the servlet I detect a severe error (in a business rule) and I want
to generate an HTTP 500 error like this:
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
Even though my servlet calls "sendError()" as shown above, control still
returns to the JSP that included the servlet which goes on its merry way,
oblivious to the error in the servlet. This is wrong. I want the JSP to
abort processing.
Any ideas on the correct way to do this?
If memory serves, the semantics for <jsp:include> (and <jsp:forward>)
is a bit vague for error cases in the JSP spec (even though I agree
that the right thing to do is to propagate errors in both cases).
If you're in a JSP 1.2 container, you may want to use the JSTL
<c:import> action instead. It has well-defined semantics for both
exceptions and status codes resulting from importing the resource.
For instance, a status code 500 results in an exception being thrown
(that you can catch with <c:catch> if you want to).
Hans
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.com
JavaServer Pages http://TheJSPBook.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com