You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jarecsni János <ja...@chello.hu> on 2001/04/25 06:58:18 UTC

Sun J2EE RI, JSP, Include, ErrorPage -- cannot use an errorpage with dinamically included JSPs

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.


RE: Sun J2EE RI, JSP, Include, ErrorPage -- cannot use an errorpage with dinamically included JSPs

Posted by Jarecsni János <ja...@chello.hu>.
Hi,

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.

Cheers,
Janos

> -----Original Message-----
> From: Jarecsni János [mailto:jarecsni.janos@chello.hu]
> Sent: Wednesday, April 25, 2001 6:58 AM
> To: tomcat-user@jakarta.apache.org
> Subject: Sun J2EE RI, JSP, Include, ErrorPage -- cannot use an
> errorpage with dinamically included JSPs
>
>
>
> Hi!
>
> I have a very unnoying problem. In a J2EE application I use a "master JSP"