tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 13446] New: - Invalide error page with request attribute.
Date Wed, 09 Oct 2002 09:24:14 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13446>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13446

Invalide error page with request attribute.

           Summary: Invalide error page with request attribute.
           Product: Tomcat 4
           Version: 4.0.1 Final
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Catalina
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: philippe.prados-renexter@renault.com


In a servlet, i want to forward to a JSP error page. For transmit the current 
exception, i set the attribute javax.servlet.error.exception in the request, 
and i forward to the error page. This page initialise the exception variable 
with the exception. Then, in the error page, i call response.sendRedirect
("/index.jsp");
Because the variable "javax.servlet.error.exception" live when i call the 
sendRedirect, i receive the Tomcat error page and the sendRedirect can't work.
I make a sample for check that. Create to JSP file in a webapp.
Test.jsp
========
<%@ page errorPage="TestError.jsp" %>
Test.jsp
<%
  System.out.println("Test.jsp");
  request.setAttribute("javax.servlet.error.exception",new Throwable());
  Object n=null;
  n.toString(); // This statement generate a null pointer exception
%>

TestError.jsp
=============

TestError.jsp
<%
  System.out.println("TestError.jsp");
// Next line for patch the bug
//  request.removeAttribute("javax.servlet.error.exception");
  response.sendRedirect(request.getContextPath()+"/index.jsp");
%>

Invoke the Test.jsp page. Because the NullPointerException was throw, the page 
TestError.jsp is called. This page want to send a redirect to the page 
index.jsp (must be present). But, you receive the Tomcat error page !

Because the servlet must be deconnected to JSP, normally, the JSP technique for 
manage the error can be deconnected to the servlet engine. I think, in the 
ErrorReportValve.java or ErrorDispatcherValve.c can detect this situation 
(reset this attribute AFTER the service() method, remember it's in error 
page, ...) Other servlet engine haven't this problem.

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message