I do what Craig and Daniel pointed out..at least close to it.
I do something like:
public void execute(HttpServletRequest req, HttpServletResponse res)
{
try
{
// do controller work
}
catch(Exception e)
{
// exception..put it in request so JSP page can display it.
req.setAttribute("EXCEPTION", e.getMessage());
}
finally
{
try
{
getContext().getRequestDispatcher(forwardURL).forward(req,res);
}
catch(Exception e2)
{
// log error
System.out.println("Ooopps..an error has occured forwarding to " +
forwardURL + ". MESSAGE: " + e2.getMessage());
}
}
}
I don't think this is exactly what Craig and/or Daniel do..but its simple
enough to see how it works. You can modify it as you see fit. The idea
is..any exceptions are caught and then put into the REQUEST object as a
String. The JSP page might look like this:
<%
if( request.getAttribute("EXCEPTION") != null )
{
%>
<%= request.getAttribute("EXCEPTION") %>
<%
}
%>
Since I have a pretty low-traffic site, and we include the same header on
every page, I put this code in the header.inc file that every JSP page
includes so that every page can display an error message if need be.
Otherwise, you could do special processing for exceptions if you want. This
is but one way to do it. The nice thing is..the EXCEPTION attribute
disappears after each request, so that each time the page is submitted..if
nothing happens, then no error is displayed. By using it in the session, you
have to remember to remove the object when done..unless you want it to sit
around until its gc'd.
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets