Details
-
Type:
Sub-task
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 0.6, 1.0.3
-
Fix Version/s: 1.1-beta3
-
Component/s: None
-
Labels:None
Description
Trying to use RequestDispatcher to include another controller & action fails, despite the efforts of GRAILS-304. I troubleshooted why this is the case and made things work in my application, with a few changes.
1. The UrlMappings servlet filter needs to execute for this request. There are two reasons why it won't and they need to get resolved:
a. In the web.xml, the filter-mapping element needs a <dispatcher>REQUEST</dispatcher> and a <dispatcher>INCLUDE</dispatcher> Due to the following issue I was forced to modify grails to make this change:
http://www.nabble.com/Deferred-output-of-web.xml-past-doWithWebDescriptor()-makes-some-mutations-impossible.-td18719230.html
b. The UrlMappingsFilter is a Spring OncePerRequestFilter which blocks it from working on the include. So at the point I needed to use the request dispatcher, I removed 'urlMapping.FILTERED' from the request attributes, and add it after the include.
2. The url to get the request dispatcher must start with a '/' and thus be web-app-context relative because for whatever reason if there is no leading slash, the current request looks like "/grails/controller/action" whereas "/grails" is NOT the name of the application or a controller; it appears to be an internal servlet name, however. UrlMappingsFilter gets confused at this. My workaround was simply to make sure my URLs are webapp relative.
3. The requestDispatcher deals directly with the response, even if there might be buffered text in the output stream already ("out"). So I was forced to invoke flush() beforehand.
In the comments on GRAILS-304 I asked it to be re-openned. Since it wasn't, you're looking at another bug report instead of a comment on that one ![]()
Issue Links
- is related to
-
GRAILS-979
Re: Servlet includes not handled properly by Grails
-
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits