DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ· RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=40307>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ· INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=40307 Summary: error page not shown when exception occurs in nested custom JSP tag after jsp:include Product: Tomcat 5 Version: 5.5.17 Platform: PC OS/Version: Windows 2000 Status: NEW Severity: normal Priority: P2 Component: Jasper AssignedTo: tomcat-dev@jakarta.apache.org ReportedBy: [EMAIL PROTECTED] CC: [EMAIL PROTECTED] I have a JSP page that contains a custom JSP tag nested within a custom JSP body tag, which occurs after a jsp:include tag with flush="true". When an exception is thrown from the nested custom JSP tag, I don't see the error page associated with the JSP page. This problem is only reproducible in certain circumstances, which I will explain below. I have reproduced it in Tomcat 5.5.17. Here is the code for the JSP page (nestedTagError.jsp): ****************************************************************************** <%@ taglib uri="/WEB-INF/tlds/testtagerrors.tld" prefix="testtagerrors"%> <%@ page errorPage="errors.jsp"%> <html> <head> <title> Nested Tag Page </title> </head> <body bgcolor="#ffffff"> <jsp:include page='included.jsp' flush="true"/> <testtagerrors:simpleBufferedBodyTag> <testtagerrors:noBodyTagWithError/> </testtagerrors:simpleBufferedBodyTag> <h1> Nested Tag Page </h1> </body> </html> ****************************************************************************** The noBodyTagWithError tag is the one that throws the error. Here is the code for the tag class: ****************************************************************************** package testtagerrors; import java.io.IOException; import javax.servlet.jsp.tagext.TagSupport; import javax.servlet.jsp.JspException; public class NoBodyTagWithError extends TagSupport { public int doStartTag() throws JspException { if (true) throw new RuntimeException("RuntimeException thrown from NoBodyTagWithError.doStartTag"); return SKIP_BODY; } } ****************************************************************************** simpleBufferedBodyTag is a body tag that buffers its contents and then writes them out in the doAfterBody method: ****************************************************************************** package testtagerrors; import javax.servlet.jsp.tagext.*; import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspWriter; import java.io.IOException; public class SimpleBufferedBodyTag extends BodyTagSupport { public int doStartTag() throws JspException { return EVAL_BODY_BUFFERED; } public int doAfterBody() throws JspException { try { JspWriter out = getPreviousOut(); BodyContent bodyContent = getBodyContent(); bodyContent.writeOut(out); bodyContent.clearBody(); } catch (IOException ioe) { throw new JspException (ioe); } return SKIP_BODY; } } ****************************************************************************** included.jsp just contains some simple HTML content: ****************************************************************************** <br> Some included content. <br> ****************************************************************************** Finally, errors.jsp is a simple error page: ****************************************************************************** <%@ page isErrorPage="true"%> <html> <head> <title> Error Page </title> </head> <body bgcolor="#ffffff"> <h1> ERROR </h1> <%= exception.getMessage() %> </body> </html> ****************************************************************************** When I request nestedTagError.jsp, I get the following output: ****************************************************************************** <html> <head> <title> Nested Tag Page </title> </head> <body bgcolor="#ffffff"> ****************************************************************************** This is rendered as a blank page in the browser. I would expect to get: ****************************************************************************** <html> <head> <title> Nested Tag Page </title> </head> <body bgcolor="#ffffff"> <html> <head> <title> Error Page </title> </head> <body bgcolor="#ffffff"> <h1> ERROR </h1> RuntimeException thrown from NoBodyTagWithError.doStartTag </body> </html> ****************************************************************************** This is indeed what I get if I replace the simpleBufferedBodyTag in nestedTagError.jsp with anothyer custom JSP tag, simpleBodyTag, which has the following code: ****************************************************************************** package testtagerrors; import javax.servlet.jsp.tagext.*; import javax.servlet.jsp.JspException; public class SimpleBodyTag extends BodyTagSupport { public int doStartTag() throws JspException { return EVAL_BODY_INCLUDE; } } ****************************************************************************** After doing some testing, there are 4 conditions required to reproduce this behavior: 1) The tag that throws the error (noBodyTagWithError) must be nested 2) inside a body tag that buffers its output 3) and occurs after a jsp:include tag 4) with flush="true" In other words, the error page will be shown if *any one* of these changes is made: 1) The noBodyTagWithError tag is moved outside the simpleBufferedBodyTag tag 2) A non-buffering body tag (simpleBodyTag) is used in the place of simpleBufferedBodyTag 3) The jsp:include tag is omitted 4) The jsp:include tag uses flush="false" I can upload a complete .war file and all of the source code if necessary. Also, here are the .tld and web.xml files: ****************************************************************************** <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd"> <taglib> <tlibversion>1.0</tlibversion> <jspversion>1.1</jspversion> <shortname>testTagErrorsTL</shortname> <info>TestTagErrors Tag Library</info> <tag> <name>noBodyTagWithError</name> <tagclass>testtagerrors.NoBodyTagWithError</tagclass> <bodycontent>empty</bodycontent> </tag> <tag> <name>simpleBodyTag</name> <tagclass>testtagerrors.SimpleBodyTag</tagclass> <bodycontent>JSP</bodycontent> </tag> <tag> <name>simpleBufferedBodyTag</name> <tagclass>testtagerrors.SimpleBufferedBodyTag</tagclass> <bodycontent>JSP</bodycontent> </tag> </taglib> ****************************************************************************** <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name>TestTagErrors</display-name> <servlet> <servlet-name>debugjsp</servlet-name> <description>Added by JBuilder to compile JSPs with debug info</description> <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class> <init-param> <param-name>classdebuginfo</param-name> <param-value>true</param-value> </init-param> <load-on-startup>3</load-on-startup> </servlet> <servlet-mapping> <servlet-name>debugjsp</servlet-name> <url-pattern>*.jsp</url-pattern> </servlet-mapping> </web-app> ****************************************************************************** -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]