In short, how can I get the full query string using EL in a webflow view jsp? This is what I am trying to do:
<span class="forgot-password">
<a href="forgotPasswordRequest?<%=request.getQueryString() %>">
<spring:message code="screen.welcome.link.forgotPassword" />
</a>
</span>
Except I would like to use EL instead of the scriptlet <%=request.getQueryString() %>
. It appears easy enough to get any individual parameter using ${param.someParameterName}
, but I want the whole thing. More specifically I am using CAS as an SSO provider. In order to authenticate, an app would redirect its login to CAS with a query string containing the parameter service
that is the URL to return to after successful authentication. Something like this:
?service=http%3A%2F%2Fmysite.com%3A9080%2Fwelcome
My CAS login page has a link for a forgotten password webflow. I need to propagate that service parameter to that other webflow. So I could do something like this:
<span class="forgot-password">
<a href="forgotPasswordRequest?service=${param.service}">
<spring:message code="screen.welcome.link.forgotPassword" />
</a>
</span>
But then I lose all the URL escaping. Furthermore, if there are other parameters that I want to preserve in the future, they would be lost as well.
The scriptlet currently works, but its ugly and I don't like having code (since this is true java code) in my presentation even though it is trivial. EL is certainly a much more elegant solution.
I poked around all of the Special EL variables listed in the spring documentation, but was still unable to come up with a way to get the full queryString.
-------------------------------- UPDATE --------------------------------
Ok, so I am making some ground... Turns out that the ExternalContext
interface has a getNativeRequest()
which is the actual HttpServletRequest
object. From there I can get the full query string thusly:
externalContext.getNativeRequest().getQueryString()
So now I assume that since there is a Special EL variable called externalContext, i would just do this:
${externalContext.nativeRequest.queryString}
right? Wrong! It turns out the externalContext
variable is not available from the JSP page. Anyone know why? However, there is also flowRequestScope
, which is available to the JSP and has a getExternalContext
method, so now I can do this:
${flowRequestScope.externalContext.nativeRequest.queryString}
Cool, that works... But why is it necessary? Why are only some of the Special EL variables pushed to the JSP page, and why do some of them change (viewScope
seems to have all of its values promoted up a level to root so viewScope.commandName is referenced as ${commandName} in the JSP EL)? I must be missing something fundamental in the way WebFlow works. Can someone point me in the right direction?