tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Holtfreter, Gregory" <>
Subject jsp:include bug in 4.1.27
Date Tue, 04 Nov 2003 19:03:16 GMT
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