| Author |
getParameter return null if query string contains %26
|
Ashraf Fouad
Ranch Hand
Joined: Oct 07, 2001
Posts: 80
|
|
I work with MVC model implementation recomended by IBM where I submit from a JSP to a controller servlet which redirect the request to whatever handler, I found the following behaviour, which occured on a single machine with IBM WepSphere AppServer 3.5.5 and doesn't occur on others: I printed the following with the java APIs for getting the request string, servlet path, etc..... Servlet Path = /controller. Path info = /PublishingHandler. Request URI = /vi_debug/controller/PublishingHandler. Query String = Page=displayPublishing&relatedPublishingId=3&displayPublishingClosePageParameter=/vi_debug/controller/PublishingAdministrationHandler?Page=navigate_create_show_publishing_publishing%26CategoryToNavigate=1. From the above values you can c that the query string contains key=value pairs but when I try to get the parameter values using the following code: // Obtain the request parameters Enumeration parameterEnum = p_Request.getParameterNames(); if ( parameterEnum.hasMoreElements() ) System.out.println( "Enumeration has elements" ); else System.out.println( "Enumeration don't have elements" ); // Go through them one at a time and print them out while ( parameterEnum.hasMoreElements() ) { String name = (String) parameterEnum.nextElement(); System.out.println( "Parameter name: " + name ); System.out.println( "Parameter value: " + p_Request.getParameter( name ) ); } I got the message that Enumeration don't have elements, I recognized that this happens when the querystring contains %26 I'm using this character so that I submit with a query string that have more than ? character & I wanted to keep the & that occured after the second ? Also I used the upload utility from orielly, and the form is multi-part & I concatenat some values in the query string, but I didn't get them using getParameter, Is the getParameter method not used when the form is muli-part, and if so what with used in this case? thankx for yr time.
|
Ashraf Fouad
SCJP 1.2, SCBCD 5
|
 |
Jessica Sant
Sheriff
Joined: Oct 17, 2001
Posts: 4313
|
|
ok... so the URL you were accessing looks like this: /vi_debug/controller/PublishingHandler?Page=displayPublishing&relatedPublishingId=3&displayPublishingClosePageParameter=/vi_debug/controller/PublishingAdministrationHandler?Page=navigate_create_show_publishing_publishing%26CategoryToNavigate=1. Notice you have your URI -- then a ? that defines the beginning of the query string. After that, each Name=Value pair is seperated by a & --- but then -- you have a nother ? -- I'm guessing your appserver is being confused by the 2nd ? (which normally specifies the beginning of a query string)
|
- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
|
 |
 |
|
|
subject: getParameter return null if query string contains %26
|
|
|