| Author |
Inconsistencies when trying to extract request parameters
|
|
|
| I am having some some troubles using 5.1.0.1 when trying to extract request parameters from a GET request.
I have a query string which is this:
? PC_7_0_1GNM_spf_strutsAction=!2ftransact
ionSearchResultsSelect.do!3ftransactionReference%3d1234583
There seem to be discrepencies depending on which method you call to extract the parameters
1. request.getParameter("spf_strutsAction")
This returns: "!2ftransactionSearchResultsSelect.do!3ftransactionReference=1234583"
Which is odd as it contains both paremeters?
2. request.getParameter("transactionReference")
This returns: "1234583"
Which is correct
3. request.getParameterNames()
This correctly gives me an Enumeration of two elements which i am able to extract the values as in points 1. and 2.
4. request.getParameterMap()
This gives me a Map which has a size() of 1. This is probably related to point 1.
5. request.getParameterMap().containsKey("spf_strutsAction")
This returns true
6. request.getParameterMap().containsKey("transactionReference")
This returns false
I just don't understand the consistencies!
The third party code i am using with struts is iterating over the Map returned from request.getParameterMap. As is shown from point 6. it is unable to find the "transactionReference" key.
Any help would be appreciated.
"request.getParameter("spf_strutsAction")"= "!2ftransactionSearchResultsSelect.do!3ftransactionReference=1234583"
| |
|
| That is odd behavior, just a thought - From the query string you provided, it looks like your spf_strutsAction is Portlet namespace encoded, but the other paramters aren't. Try encoding all the form parameters on the page and see if it fixes the problem.
Also - are you using JSR168 or the IBM Portlet API? Do you perform these request.getParameter checks in your doView or actionPerformed/processAction ?
> I am having some some troubles using 5.1.0.1 when
> trying to extract request parameters from a GET
> request.
> I have a query string which is this:
> ? PC_7_0_1GNM_spf_strutsAction=!2ftransact
ionSearchResu
> ltsSelect.do!3ftransactionReference%3d1234583
>
> There seem to be discrepencies depending on which
> method you call to extract the parameters
>
> 1. request.getParameter("spf_strutsAction")
> This returns:
> "!2ftransactionSearchResultsSelect.do!3ftransactionRef
> erence=1234583"
> Which is odd as it contains both paremeters?
>
> 2. request.getParameter("transactionReference")
> This returns: "1234583"
> Which is correct
>
> 3. request.getParameterNames()
> This correctly gives me an Enumeration of two
> elements which i am able to extract the values as in
> points 1. and 2.
>
> 4. request.getParameterMap()
> This gives me a Map which has a size() of 1. This is
> probably related to point 1.
>
> 5.
> request.getParameterMap().containsKey("spf_strutsActio
> n")
> This returns true
>
> 6.
> request.getParameterMap().containsKey("transactionRefe
> rence")
> This returns false
>
> I just don't understand the consistencies!
> The third party code i am using with struts is
> iterating over the Map returned from
> request.getParameterMap. As is shown from point 6. it
> is unable to find the "transactionReference" key.
>
> Any help would be appreciated.
>
>
>
> "request.getParameter("spf_strutsAction")"=
> "!2ftransactionSearchResultsSelect.do!3ftransactionRef
> erence=1234583"
| |
|
| I am simply using the following link:
<html:link page="/transactionSearchResultsSelect.do" paramId="transactionReference" paramName="transactionItem" paramProperty="txnRef">
mylink
</html:link>
| |
|
| html:link page="/transactionSearchResultsSelect.do" paramId="transactionReference" paramName="transactionItem" paramProperty="txnRef"
mylink
html:link
| |
|
| Remember that the struts url(complete with url paramters) is appended as a single url parameter to the portal url.
I believe the problem is with IBM's implementation of the HttpServletRequest. The concrete class is com.ibm.wps.struts.base.WpsStrutsPortletRequestWrapper (in wp.struts.legacy.base.jar)
The implementation of getParameter(String) must delegate to some internal methods which are able to extract the struts url parameters from the single portal url parameter.
However there is no specific implemtation for getParameterMap() which means it must delegate up to PortletRequest.getParameter(). This has no way of manipulating the query string to get struts parameters.
What a pain!
|
|
|
|