How to get parameters value as it is from the URL with JSP

sumit kumar

I have a value like var=P+q+EvhE951eg/I5nz1vi/w2YpJdH+v/vSPaQNg/I=

I pass this parameter in url like

http://localhost/proj/home.jsp?var=P+q+EvhE951eg/I5nz1vi/w2YpJdH+v/vSPaQNg/I=

Now In home.jsp i want to use this value of var as it is.But when i do

String var=request.getParameter("var"); var get the value

"P q EvhE951eg/I5nz1vi/w2YpJdH v/vSPaQNg/I=" notice it replace + with space.

So can anyone help me to resolve this problem.

user2575725

Try encoding params like this:

class Ideone
{
    public static void main (String[] args) throws java.lang.Exception
    {
        String param = "P+q+EvhE951eg/I5nz1vi/w2YpJdH+v/vSPaQNg/I=";
        System.out.printf("Orginal Param: %s\n", param);
        param = java.net.URLEncoder.encode(param, "utf-8");
        System.out.printf("Encoded Param: %s\n", param);
    }
}

Output:

Orginal Param: P+q+EvhE951eg/I5nz1vi/w2YpJdH+v/vSPaQNg/I=
Encoded Param: P%2Bq%2BEvhE951eg%2FI5nz1vi%2Fw2YpJdH%2Bv%2FvSPaQNg%2FI%3D

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related