• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem passing jsp:param

 
Deb Sadhukhan
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I pass a string as jsp:param value in jsp:include containing + char?



Problem I'm facing is toJsp.jsp is receiving the parameter as "select col3 1 from tab", + char is replaced by space.

App is hosted on websphere.

Thanks
 
Schandha Ravi
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I don't know why there is a problem. THe code which you posted worked perfectly fine for me. I just replace <jsp:include> to <jsp:forward> but I believe that should not pose any problem. I printed the value of the parameter in servlet and I got "+" printed.

I did this on weblogic server. But I'm sure this is not container dependent.
 
Deb Sadhukhan
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I cannot do jsp:forward as the logic demands jsp:include. Believe me, I'm also surprised by this problem.

I'm running on WebSphere.
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The plus sign is considered a place holder for the space character. The jsp:param will encode the URL for you so it shouldn't be a problem (the + will be encoded to %2B).

How are you accessing the values? It looks to me like it is being passed through a decoder once to often The request.getParameter(parameterName) will decode it for you first. Are you doing any other option that also attempts to decode the URL parameter?
 
Deb Sadhukhan
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm doing request.getParameter(<parmName>) to get back the param value. What other way value can be decoded? I don't think I'm decoding more than once. I think it's not encoding to start with.

Just to be clear, I'm testing using WebSphere 5.1 test server.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting.

I wrote a little test case and it appears that there are discrepancies with how the containers handle this.

Under Tomcat, the value is properly encoded and the + makes it through unscathed. Under Resin however, the value is not encoded and the plus is interpreted as an encoded space.

Which is the bug?

Let me dig into the JSP Spec and see...
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Deb Sadhukhan:
I'm doing request.getParameter(<parmName>) to get back the param value. What other way value can be decoded? I don't think I'm decoding more than once.


Not sure if you were passing the value directly throuh URLDecoder.decode() or if you were using some other layer that also decoded. Looks as though not.

Originally posted by Deb Sadhukhan:
I think it's not encoding to start with.


That also could be the case ... see below

Originally posted by Deb Sadhukhan:
Just to be clear, I'm testing using WebSphere 5.1 test server.


What version of the JSP spec does WebSphere 5.1 support? JSP 2.0 says the jsp:param must URLEncode the parameter, whereas older versions of the spec do not say so. You may have to pass the parameter like:


But this code would break for any server that does support the JSP 2.0 spec because the result would be double encoded...
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Section JSP.5.6:
The parameter names and values specified should be left unencoded by the
page author. The JSP container must encode the parameter names and values
using the character encoding from the request object when necessary. For
example, if the container chooses to append the parameters to the URL in the
dispatchedrequest,boththenamesandvaluesmustbeencodedasperthecontent
typeapplication/x-www-form-urlencoded in the HTML specification.
So the Tomcat behavior is correct and the Resin behavior (and apparently Websphere) are not.
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
Section JSP.5.6: So the Tomcat behavior is correct and the Resin behavior (and apparently Websphere) are not.


For JSP 2.0. For JSP 1.2 this behavior was not defined (JSP.4.4-4.6 for in the JSP 1.2 spec for applicable paragraphs). So if the versions of WebSphere and Resin in question don't claim to be JSP 2.0 containers the behavior isn't a bug.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Resin 3 is JSP 2 compliant, so it's definitely a bug there. If I'm not mistaken, WebSphere 5 is JSP 1.x.
 
Deb Sadhukhan
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
WebSphere 5 is JSP 1.2. So that's the issue here. Value is not encoded to start with.

Thanks much for the help!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic