tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jarecsni János <>
Subject FW: Sun J2EE RI, JSP, Include, ErrorPage -- cannot use an errorpage with dinamically included JSPs
Date Wed, 25 Apr 2001 07:00:26 GMT


I have a very unnoying problem. In a J2EE application I use a "master JSP"
as a template for generating predefined screens (the idea is borrowed from
the demo application PetStore). This JSP includes several other JSPs (for
the top, left side, right side, central, bottom positions). What JSPs should
be included for a given view is defined for each screen in a configuration
object. Okay, this is quite simple so far, and what is more, it is working

The problem arises when one decides to add error handling. If you add the

	<%@ page errorPage="errorpage.jsp" %>

directive to an included page, and throw an exception from that page, the
JSP container says that it cannot forward to the errorpage "as OutputStream
or Writer has already been obtained" (throws a
java.lang.IllegalStateException) This happens when you use the <jsp:include>
tag, the one which enables you to use an expression for defining its "page"
attribute. It is essential for us, since we want to say something like the
following in our template.jsp:

	<jsp:include page="<%= currentScreen.get("TOP") %>" flush="true">
	// My Tomcat in J2EE 1.2.1 says "flush="true" is obligatory in JSP 1.0" so
I use it in this form

This line would dinamically include the JSP defined in the actual "screen"
for the topmost area in the template. So this would be fine, but it does not

The whole thing works fine with the

	<%@ include file="file.jsp" %>

tag. So this tag does what I really need: it glues all included JSPs
together, parses them, greating one big JSP (one servlet finally), which
uses a common errorpage, so when I throw an exception from one of the
included JSPs, the error page gets called. The only problem is that this tag
does not accept an expression, only a literal string, so you cannot say:

	<%@ include file="<%= currentScreen.get("TOP") %>" %>

Rather annoying, isn't it?
I would appreciate any kind of urgent help.


I forgot to mention before, that I tested Sun's PetStore Demo application in
this respect, and it _failed_ also... So JSP error handling does not work
(!) in Sun's demo application, either.

View raw message