Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Apache Tomcat »

Re: Character encoding

Mester József

2006-12-15

Replies:

Hello Mark

>This is unlikely to help you and may be read-only on your JVM.

>You don't say what doesn't work but generally the following is required:
>set URIEncoding="UTF-8" on the connector
>set the the correct response encoding on every response (you can do
>this per page or use a filter to do this for all pages)
Ok. Let's see my problem.
I have a form with text input box. I type Árvíztűrő tükörfúrógép and I get " ÃrvíztűrÅ tükörfúrógép
  "

Beautiful isn't it?
The page is:

<%@(protected)"%>
<%@(protected)"%>

<!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>Try encoding</title>
  </head>
  <body>
  <% try {
    request.setCharacterEncoding("UTF-8");
  }
  catch (Exception ex) {
    out.println("Bad something: " +ex.getMessage());
  } %>
  Hello
  <%=request.getParameter("nev")%>
  <br>
  <form accept-charset="UTF-8" action="index.jsp" method="POST">
    <input type="text" name="nev">
    <input type="submit" value="Send name">    
  </form>
 
  </body>
</html>



>If you use a database make sure that you persist your data in the
>correct encoding.
If my text came from database everything is correct.

>If you convert from bytes to characters or characters to bytes makde
>sure you use the correct encoding.
I don't.



Joe





   
___________________________________________________________
Try the all-new Yahoo! Mail. "The New Version is radically easier to use" – The Wall Street Journal
http://uk.docs.yahoo.com/nowyoucan.html
©2008 junlu.com - Jax Systems, LLC, U.S.A.