Hi Guys,
I want to read a parameter from my query string and display it in my JSP page.
e.g. "Results for your query JSP Query returned 10 results."
I am using the following JSP code to grab the parameter from my querystring
All works fine unless someone searches for a piece of text which contains a script tag. Instead of displaying the script tag the page attempts to execute the code.
I attempted to fix this by using :
Now the code is not be executed but it is displaying the encoded charaters
e.g Results for your search query
Your search for %3Cscript%3Eale rt%28%22hello%2 2%29%3B%3C%2Fsc ript%3E returned 0 results.
Can anyone tell me how to prevent this from happening?
Thanks in advance.
I want to read a parameter from my query string and display it in my JSP page.
e.g. "Results for your query JSP Query returned 10 results."
I am using the following JSP code to grab the parameter from my querystring
Code:
String queryStr = (String) request.getParameter("querystr")
I attempted to fix this by using :
Code:
URLEncoder.encode(queryStr);
e.g Results for your search query
Your search for %3Cscript%3Eale rt%28%22hello%2 2%29%3B%3C%2Fsc ript%3E returned 0 results.
Can anyone tell me how to prevent this from happening?
Thanks in advance.
Comment