I'm sending مرحبا characters from JSP to servlet and in servlet i'm receiving the characters in this format ÙØ±ØØ¨Ø§. i want to know which one is converting this and which encoidng they are using.
If i pass these characters in POST Method, i'll receive data as it is.
i'm using JDK 1.6, Tomcat 7.
This is the JSP.
<%@page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title></head><body><form method="get" action="register">
Name:<input type="text" name="userName"/><br/><br/>
<input type="submit" value="SUBMIT"/>
</form></body></html>
This is the servlet.
public class Register extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
System.out.println("System: file.endcoding=" + System.getProperty("file.encoding"));
String str= request.getParameter("userName").trim();
RequestDispatcher rd = request.getRequestDispatcher("Display.jsp");
System.out.println("before encoding and decoding the string : "+str);
request.setAttribute("beforeconvert",str);}catch(Exception e){}}