request include attributes missing in the included jsp
ranjix Jun 22, 2010 12:09 PMHey guys, not sure if this is the right place or maybe I should just open a bug/issue/ticket with the Tomcat team itself. I might do that too.
Anyway, I do have an issue with the dynamically include jsps. Let me see if I can describe this properly.
I do have 2 jsp pages - page1.jsp, page2.jsp, and a filter which executes on every jsp request.
page1.jsp
...
<jsp:include page="page2.jsp">
...
page2.jsp
...
Filter:
if (request.getAttribute("javax.servlet.include.request_uri") != null)...
The issue here is that when the filter gets executed on the included jsp, the attribute is null. As far as I understand, based on the Servlet 2.5 spec, these attributes should be set.
Kind of tracked the problem through Tomcat code, and the issue, as far as I understand, is in org.apache.catalina.core.ApplicationHttpRequest class, where there is a setAttribute method that DOESN'T add the attribute to the request if the attribute is "special" (and the javax.servlet.include attributes are special). If I modify the method a little to add the attribute regardless of how special the attribute is, then the code works fine. The other containers I'm working with (WebLogic, WebSphere), do add the attribute on the include.
Any idea how come Tomcat is different, and, maybe even more important, how can I figure out in the filter executing on the include, if I'm in an included jsp or not? (the attribute check fails)...
thanks/
ranjix