0

I'm trying to construct an URL with query string containing other characters (hebrew in my case). However, when my webapp receives the request, the extracted request parameters are gibrish...

How can I resolve this?

new URL("http://localhost:8080/SRV/page.jsp?param=" + URLEncoder.encode("heb text", "UTF-8")).openConnection();

target page:

<%
    System.out.println("Receive: " + request.getParameter("param"));
%>

I'm using tomcat6, jdk6, windows7 x64

edit: this is my page declaration:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
2
  • 1
    Does yout JSP use a UTF-8 charset? Commented Nov 9, 2012 at 1:24
  • Welcome to SO. As suggested by Le Guen try adding <%@page contentType="text/html;charset=UTF-8"%> to your jsp and output the param in the web page. Commented Nov 9, 2012 at 1:30

1 Answer 1

2

Take a look at the $TOMCAT_HOME/conf/server.xml file and check the encoding setting:

<Connector port="8080" ... URIEncoding="UTF-8" />

It appears that Tomcat needs this setting for UTF-8 to work for HTTP request values, such as request parameters.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.