Java Mailing List Archive

http://www.junlu.com/

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

Encoding/Decoding

Joe Russo

2007-07-31


This test page results are shown:
Latin Character input Capital A with Circumflex ^: Â
Greek Character input Omega: Ù

without decode=Latin%3A+%C3%82+Greek%3A+%C3%99

with decode=Latin: Â Greek: Ù

It appears the encoding is set to IS0 8859-1 since the character encoding maps correctly to that character set.

Here are my server.xml settings:
<Connector port="8009" URIEncoding="UTF-8" useBodyEncodingForURI="true"
         enableLookups="false" redirectPort="8443" debug="1"
         protocol="AJP/1.3" />

<Connector port="8080" URIEncoding="UTF-8" useBodyEncodingForURI="true"
         maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
         enableLookups="false" redirectPort="8443" acceptCount="100"
         debug="8" connectionTimeout="20000"
         disableUploadTimeout="true" />

Any ideas what I am doing wrong would be greatly appreciated.
Joe


-----Original Message-----
From: root [mailto:root@(protected)]
Sent: Tuesday, July 31, 2007 11:00 AM
To: Russo, Joe
Subject:

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

<html>
<head> <title>Character Encoding/Decoding UTF-8</title> </head>
 <body bgcolor="White">
<%
 //request.setCharacterEncoding("UTF-8");
 //response.setCharacterEncoding("UTF-8");
 //response.setContentType("text/html;charset=UTF-8");
 ConnectionPool cp = null;
 Connection con = null;
 String url = null; String user = null;
 String password = null; String dbDriver = null;
 String schemaName = null; String ms_no = null;
 String newl, newg = null; boolean isConnected = false;
 MsSupplimentaryDetails msd = new MsSupplimentaryDetails();
 String encoding = null; char greek = 0xD9; char latin = 0xC2;
%>
<%
  dbDriver = "oracle.jdbc.driver.OracleDriver";
  schemaName = "dba55688!!a;@@(protected)";
  url    = "jdbc:oracle:thin:@(protected)";
  ms_no = "CAN-06-2483";
  //ms_no = "CAN-07-0321";
  encoding = "UTF-8";
  newl = "Latin: ";
  newg = "Greek: ";
  //encoding = "IS0-8859-1";
  //encoding = "ISO-10646";
  //encoding = "IS0-8859-16";

  cp = new ConnectionPool(url, user, password, dbDriver, 1, 1, schemaName);
  con = cp.getConnection();
  msd.setConnection(schemaName, con);
   
 MsSupplimentaryDetails[] msd_arr = msd.fetchData("where ms_no = '" + ms_no + "'");
%>
 <form name="ChangeDecision" method="post">
 <table border="0" width="100%" cellpadding="4" cellspacing="1">
 <tr valign="top">
 <td bgcolor="#cfcfcf"><font face="arial" size="2"><b>
   <div align="center">MS Supplimentary Details</div></b>
   </font></td>
 </tr>
 <tr>
   <td>Latin Character input Capital A with Circumflex ^: <%=latin%> </td>
 </tr>
 <tr>
   <td>Greek Character input Omega: <%=greek%> </td>
 </tr>
 </table>

 </form>
<%
 out.write("<br>");
 out.write("<blink><font color=blue>without decode</font></blink>=" +
   msd_arr[0].getAbstracts());
 
 String abstracts = newl + latin + " " + newg + greek;
 abstracts = URLEncoder.encode(abstracts, "UTF-8");
 abstracts = RRUtil.validateString(abstracts,true);
 try{
   msd.update("SET abstract=''" , " WHERE MS_NO='" + ms_no + "'");
   msd.update("SET abstract='" + abstracts + "'" , " WHERE MS_NO='" + ms_no + "'");
   con.commit();
 }
 catch(Exception ex){
   out.write("<br><br> exception:" + ex);
 }
 out.write("<br><br>");
 out.write("<blink><font color=blue>with decode</font></blink>=" +
 URLDecoder.decode(msd_arr[0].getAbstracts(),"UTF-8"));
%>

 </body>
 </html>


---------------------------------------------------------------------
To start a new topic, e-mail: users@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.