tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jarecsni János <jarecsni.ja...@chello.hu>
Subject Sun J2EE RI, JSP, Include, ErrorPage -- cannot use an errorpage with dinamically included JSPs
Date Wed, 25 Apr 2001 04:58:18 GMT

Hi!

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
fine.

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
work.

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.

Cheers,
Janos.


Mime
View raw message