Search code examples
servletsurl-encodingquerystringparameter

Servlet stripping parameter values because of # character


My URL is http://175.24.2.166/download?a=TOP#0;ONE=1;TWO2.

How should I encode the parameter so that when I print the parameter in the Servlet, I get the value in its entirety? Currently when I print the value by using request.getParameter("a") I get the output as TOP instead of TOP#0;ONE=1;TWO2.


Solution

  • You should encode it like this http://175.24.2.166/download?a=TOP%230%3BONE%3D1%3BTWO2 . There are a lot of the encoders in Java, you can try to use URLEncoder or some online encoders for experements