Hello everyone,
I am facing one issue when passing a parameter in a http request and trying to retrieve the values in the
servlet.
Inside one index.jsp, I have a field /parameter with value as below:
Sample code:
<%
URLDecoder urlDecoder = new URLDecoder();
String str1="";
str1=urlDecoder.decode("qDqKNTYGxzvhVXsFgpX%2BZe4u7Pu6bTdU9P9KQonpEgZXAByZ8xlrvOVuShZVXbNkBnQtsCLsqdlE%0D%0AFsy7jHC%2FYLXW");
System.out.println(str1);
str = "http://localhost:8080/WebApp2/Servlet2?iburl="+str1;
System.out.println(str); //prints : qDqKNTYGxzvhVXsFgpX+Ze4u7Pu6bTdU9P9KQonpEgZXAByZ8xlrvOVuShZVXbNkBnQtsCLsqdlE
Fsy7jHC/YLXW
%>
I have set this value in a parameter called "myParam"in the in form action url, as
http://localhost:8080/WebApp2/Servlet2?myParam="+str1
In servlet2, ideally when i retrieve the value as: request.getParameter("myParam"); it should print the same output as above in the
jsp, howver, issue is, it is printing as below:
qDqKNTYGxzvhVXsFgpX Ze4u7Pu6bTdU9P9KQonpEgZXAByZ8xlrvOVuShZVXbNkBnQtsCLsqdlE
I would like to know why is request.getParameter("myParam"); not able to fetch the exact value passed in the http url. If it has a default decoding behavior, how to fetch the actual value which is passed in the url?
Appreciate and thanks in advance for your suggestions/solutions.
Cheers.