|
OK.
The URL in my browser bar is: http://localhost:8080/tables-admin/createProject.htm getRequestURI returns: /tables-admin/jsp/createProject.jsp request.getAttribute("javax.servlet.forward.request_uri") returns: null This is what I added to the JSP: <p>1 <%= request.getRequestURI() %></p> <p>2 <%= request.getAttribute("javax.servlet.forward.request_uri") %></p> Glassfish is a JEE 1.5 implementation (whereas most appservers are still 1.4). It uses the 2.5 servlet spec. Could there be a change in spec, or is it a bug in the servlet container? Gareth Just a thought: could either
org.springframework.web.servlet.view.InternalResourceViewResolver - or - org.springframework.web.servlet.view.JstlView be overwriting the URI by calling the JSP in the wrong way? Gareth This is strange since Spring's InternalResourceView even checks for the presence of those attributes and exposes them itself if not present already. See InternalResourceView, line 184... You could put a breakpoint in the debugger there when running within GlassFish.
InternalResourceView's behavior should be appropriate there; this seems to work fine on all other containers. Still, something's going wrong between InternalResourceView and GlassFish there... You could try to code a simple servlet and manually call RequestDispatcher.forward, triggering a forward to your JSP. I wonder whether the "javax.servlet.forward.request_uri" attribute is available then... This would be the ultimate test of GlassFish's raw forward behavior. There is no relevant change in the Servlet 2.5 spec as far as I can see. Juergen WAR containing a simple servlet and a JSP to test RequestDispatcher forwarding behaviour. Source included.
OK. Assuming I understood you correctly (see attached WAR), here are the results.
Value in browser address bar: http://localhost:8080/jsp-forward-test/ In servlet before forward: request.getRequestURI(): /jsp-forward-test/ request.getAttribute("javax.servlet.forward.request_uri"): null As seen by JSP after forward request.getRequestURI(): /jsp-forward-test/jsp/fwdTarget.jsp request.getAttribute("javax.servlet.forward.request_uri"): /jsp-forward-test/ Gareth OK. I set logging to FINEST on
and then click on org.springframework.web.servlet.view - and - org.springframework.web.util (to pick up WebUtils) This is the log output [#|2008-01-31T13:07:45.804+0000|FINE|sun-appserver9.1|org.springframework.web.servlet.view.InternalResourceViewResolver|_ThreadID=17;_ThreadName=httpSSLWorkerThread-8080-1;ClassName=org.springframework.web.servlet.view.AbstractCachingViewResolver;MethodName=resolveViewName;_RequestID=92451d78-020f-47dc-9561-1748c0c3ad6f;|Cached view [createProject]|#] [#|2008-01-31T13:07:45.805+0000|FINE|sun-appserver9.1|org.springframework.web.servlet.view.JstlView|_ThreadID=17;_ThreadName=httpSSLWorkerThread-8080-1;ClassName=org.springframework.web.servlet.view.AbstractView;MethodName=render;_RequestID=92451d78-020f-47dc-9561-1748c0c3ad6f;|Rendering view with name 'createProject' with model null and static attributes {}|#] [#|2008-01-31T13:07:45.805+0000|FINE|sun-appserver9.1|org.springframework.web.servlet.view.JstlView|_ThreadID=17;_ThreadName=httpSSLWorkerThread-8080-1;ClassName=org.springframework.web.servlet.view.InternalResourceView;MethodName=renderMergedOutputModel;_RequestID=92451d78-020f-47dc-9561-1748c0c3ad6f;|Forwarding to resource [jsp/createProject.jsp] in InternalResourceView 'createProject'|#] I am now at a loss as I am not sure what to look at. Any ideas? I've reproduced this problem on GlassFish in the meantime, and also verified that it works fine on Tomcat 6 (which is Servlet 2.5 compliant as well) - with the "javax.servlet.forward.request_uri" attribute exposed as expected on Tomcat but not on GlassFish...
I'll do some debugging to find out what the root cause is. I'll keep you posted. Juergen Apparently GlassFish gets confused by pre-exposed forward attributes, which Spring's InternalResourceView does in order to enforce the presence of those attributes even on Servlet 2.3 and misbehaving Servlet 2.4 containers (such as OC4J)...
We haven't heard of a conflict there before, hence the exposure of those attributes was done on any container. I've revised this now to skip that manual exposure on Servlet 2.5 or above, relying on the servlet container to fully implement those forward attributes itself... (which is a Servlet 2.4 spec feature anyway). This fix should be available in tonight's 2.5.2 snapshot already (-389, available from http://static.springframework.org/downloads/nightly/snapshot-download.php?project=SPR). Feel free to give it a try... Juergen Just plugged the jars into my application and I seem to be back in business.
Thanks Gareth |
|||||||||||||||||||||||||||||||||||||||||||||||||||||
Can you please - in the same JSP - check what request.getRequestURI() and request.getAttribute("javax.servlet.forward.request_uri") result in? Spring checks the latter first, then falling back to the former... which should work fine according to the Servlet 2.4 spec.
Juergen