The "+" character is replaced with a space in the Servlet request parameters

When text is entered into a JSP text field that contains a "+" character, it is replaced with a space when the parameter value is retrieved inside the servlet via request.getParameter ("abc").

I read several blogs and found out what needs to be encoded in order to successfully read the exact text, but I don't understand it. Can someone please help me on this.

+3


source to share


2 answers


+

is illegal within a parameter value because it is a specific delimiter between parameter name-value pairs. You need URLEncode

both parameter names and parameter values before submitting .



+1


source


Unable to play.

Even with

<form action="rep" method="GET">
    <input name="foo" type="text"/>
</form>

      



the servlet in rep

(even though is is a jsp) gets it foo=a%2Bb

as a query string when I type a+b

in the input field.

I am assuming you are manually generating the request, in which case you have to url encode the parameters.

0


source







All Articles