0

I am using JSP pages and I am trying to get the UTF-8 value from query string using the statements as below request.getparameter("q");

It is working fine, it gives me the appropriate results but when I am trying it using IE9 it gives me ????? instead of unicode value.

My question is how do I get proper unicode value from query string using JSP that will gives correct values on all browser including IE, and what statements I need to add within JSP page to get correct values at IE as well.

Please help me in this regard.

thank you

Michal Borek
  • 4,584
  • 2
  • 30
  • 40

1 Answers1

1

In the jsp page directive you need to set content-type to utf-8 (for each jsp page)

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="ISO-8859-1" %>

If still problem persist then use this SO question to handle encoding for DB, Tomcat. HERE

Community
  • 1
  • 1
Alpesh Gediya
  • 3,706
  • 1
  • 25
  • 38
  • after adding above code in jsp check if your HTML code contains ""? – Alpesh Gediya May 29 '13 at 08:51
  • <%@page contentType="text/html;charset=UTF-8"%> <%@page import="java.util.*,java.io.*,java.lang.*,java.io.*,java.sql.*, java.sql.ResultSet, java.lang.String;"%> ; <% try{ response.setContentType("text/html"); request.setCharacterEncoding("UTF-8"); String val =request.getParameter("q"); out.println("val :"+val); } catch(Exception e) { out.println(ex.getMessage); } %> – Ramandeep Kaur May 29 '13 at 09:22