Problem In Decoding Parameters In Get Method, Jsp
Solution 1:
Decoding of the GET query string is handled by the servletcontainer, not by the Servlet API. It's unclear which servletcontainer you're using, so I can't give a detailed answer. In for example Tomcat, it's configureable by URIEncoding
attribute in the <Connector>
element in /conf/server.xml
.
<ConnectorURIEncoding="UTF-8">
Configuration is similar in other servletcontainers.
Then you can remove the unnecessary URLDecoder
line. The getParameter()
already returns the decoded parameter.
See also:
Unrelated to the actual problem, I strongly recommend to replace scriptlets by EL and use JSTL fn:escapeXml
to prevent XSS attacks.
var lat = ${fn:escapeXml(param.lat)};
var lng = ${fn:escapeXml(param.lng)};
var venue = "${fn:escapeXml(param.venue)}";
See also:
Solution 2:
What does your JSP header look like?
Make sure it says something like:
<%@ page contentType="text/xhtml;charset=UTF-8"%>
You can also check HTTP headers you are getting when invoking your JSP. Make sure your response is UTF-8 encoded.
Solution 3:
Maybe this method is overriding the wrong encoding: request.setCharacterEncoding("UTF-8")
Probably you should check the encoding to be used in your JSP header or in the request header.
Charlie
Post a Comment for "Problem In Decoding Parameters In Get Method, Jsp"