tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Holtfreter, Gregory" <>
Subject RE: include bug in 4.1.27
Date Wed, 05 Nov 2003 18:49:28 GMT

I have attached patches for two files which I believe fixes the problem I have described below.
These are patches to the files from HEAD which would not address Tomcat 4.x but could be applied
to the TOMCAT_4 branch also. 

Basically, the change I have made is to pass the application variable from the compiled JSP
to the JspRuntimeLibrary.include(...) method and use it, if not null, to obtain a RequestDispatcher,
otherwise use the request as before.

-----Original Message-----
From: Holtfreter, Gregory 
Sent: Tuesday, November 04, 2003 1:03 PM
Subject: jsp:include bug in 4.1.27

I am currently porting webapps to Tomcat(4.1.27) from WL and believe I may have found a bug
with the 
implementation of the jsp:include action tag. The problem I found is that when using the jsp:include
tag in a page which resides in a context which differs from the request's initial context
the page being included is not found. (The crossContext attribute of the Context element has
been set to true.) 

An example may better explain this:

	one.jsp source:
		<% config.getServletContext().getContext("/WebappTwo").getRequestDispatcher("/two.jsp").include(request,response);

	two.jsp source:
		<jsp:include page="/three.jsp" flush="true"/>
	three.jsp source:

The text inside of WebappTwo/three.jsp will not be included in WebappTwo/two.jsp output when
requesting WebappOne/one.jsp. However, if we move WebappTwo/three.jsp to WebappOne the output
is included in the output of WebappTwo/two.jsp. 

I think that the cause of this is that JspRuntimeLibrary.include(...) uses the request to
obtain a RequestDispatcher and the request is pointing to the initial context:

RequestDispatcher rd = request.getRequestDispatcher(resourcePath);
rd.include(request, new ServletResponseWrapperInclude(response, out));

The JSP 1.2 spec seems to say that jsp:include should be relative to the current page:

"A <jsp:include .../> element provides for the inclusion of static and dynamic
resources in the same context as the current page."

Greg Holtfreter
Software Engineer
Encyclopaedia Britannica  

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message