Posted By:
Haig_Haig
Posted On:
Thursday, February 27, 2003 06:52 AM
Hello, I have the following application architecture: A button on a JSP is clicked, which sends the request to the Controller servlet. This servlet gets a RequestDispatcher and forwards to another specified JSP. The problem is where I check to see that the response is committed, it goes through my finally block and executes, which is not expected behaviour. This works on Tomcat 4.0. The code fragment for that is as follows: public void doPost (HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { RequestDispatcher rd getServletContext().getRequestDispatcher(JSP); rd.forward(req,resp); } catch
More>>
Hello, I have the following application architecture:
A button on a JSP is clicked, which sends the request to
the Controller servlet. This servlet gets a
RequestDispatcher and forwards to another specified
JSP. The problem is where I check to see that
the response is committed, it goes through my
finally block and executes, which is not expected
behaviour. This works on Tomcat 4.0.
The code fragment for that is as follows:
public void doPost (HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
RequestDispatcher rd getServletContext().getRequestDispatcher(JSP);
rd.forward(req,resp);
}
catch (Exception e) {
System.err.println(e.getMessage());
}
finally {
try {
if (!(resp.isCommitted())) {
RequestDispatcher rdFinal = getServletContext().getRequestDispatcher(JSPERROR);
rdFinal.forward(req,resp);
}
}
catch (Exception e) {
System.err.println(e.getMessage());
}
finally {
try {
if (!(resp.isCommitted())){
resp.setContentType("text/html");
PrintWriter out = resp.getWriter();
out.println("ERROR");
}
}
catch (Exception e) {
System.err.println(e.getMessage());
}
}
}
}
As you can see, I have plenty of error handling, but there are no exceptions being thrown, only my response not being committed.
Isn't a response committed after a rd.forward()?
Much thanks,
Haig
<<Less