Hi Anthony,
thank you very very much for your detailed explanation :)
you helped me a lot,
As you said , with windows notepad editor i opened and
re-saved my jsp file with utf-8 encoding,
now another proble arose :(
this time the data entered by the user from a html form(inside the jsp file)
are corrupted.When i remove the
"contentType="text/html; charset=utf-8"
from the jsp file, the dynamic data is displayed okey , but this time
the static characters on the jsp file(html content) are corrupted.
how to fix this problem.
i am posting one of my jsp file for your reference.
please guide me, i am stuck here .
everything except this okey, jsut because of this
i can't hand this application to our customers.
thanks a lot for your help again
best regards :)
my jsp file:

<%@  page language="java" contentType="text/html; charset=utf-8"%>
<%@  page import="java.sql.*,com.oreilly.servlet.*" %>
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="../css/style.css">
<title>修改產品</title>

</head>

<%
   int origtyp=Integer.parseInt(request.getParameter("typ"));
    int typ=origtyp;
   int  no=Integer.parseInt(request.getParameter("id"));
   String title=request.getParameter("title");
  String content=request.getParameter("content");
  String pic=request.getParameter("pic");
  int hit=Integer.parseInt(request.getParameter("hit"));
  float  price=Float.parseFloat(request.getParameter("price"));
  float  dis_price=Float.parseFloat(request.getParameter("disprice"));
  String type="";
   Class.forName("org.gjt.mm.mysql.Driver");

   Connection conn = DriverManager.getConnection("jdbc:mysql:///clg");

    Statement stmt = conn.createStatement ();

  %>
<body topmargin="20" leftmargin="15" bgcolor="#FFFFFF" >
<form method="POST" action="pr_update.jsp?id=<%=no%>" enctype="utf-8">

  <div align="center"><center>
      <table border="1" cellspacing="2" width="600"
bordercolorlight="#000000" bordercolordark="#FFFFFF">
        <tr bgcolor="#006cd9">
          <td width="100%" height="20">
            <p align="center"><b><font
      color="#FFFFFF">資源網修改產品� �</font></b>
          </td>
    </tr>
    <tr align="center">
      <td width="100%">
            <table border="0" cellspacing="1" width="100%">

              <tr>
                <td width="15%" align="right" height="30">
    <b><font color="#0080C0">產品標題:</font></b></td>
                <td width="85%" height="30">
                  <input type="text" name="title" size="70"
          class="smallinput" maxlength="255" value="<%=title%>">
                  <font color="#FF0000" size="3">*</font> </td>
              </tr>
              <tr>
                <td width="15%" align="right" height="30"><b>
    <font color="#0080C0">產品欄目:</font></b></td>
                <td width="85%" height="30">
                  <select class="smallSel" name="typ" size="1">
  <% int Typ;
  ResultSet rs = stmt.executeQuery ("select * from prod_types");

le(rs.next()){
   Typ=rs.getInt(1);
   %>
    <option  value=<%=Typ%> name=typ
 <% if (Typ==typ) { %> selected <%}%>
 ><%=rs.getString(2)%></option>
     <%} file://end of while loop %>
                  </select>
                </td>
              </tr>
     <tr>
                <td width="15%" align=right><b><font color="#0080C0">
    圖片名稱:</font></b></td><td width="85%">
                  <input type="text" name="pic" size="15"
                  class="smallinput" maxlength="25" value="<%=pic%>">
                </td> <tr>
    <td width="15%" align=right><b><font color="#0080C0"> extension: </font></b></td>
    <td width="85%"><input type="text" name="ext" size="4"
                  class="smallinput" maxlength="4" value="jpg"></td> </tr>
     <tr> <td width="15%" align=right> <b><font color="#0080C0">price :</font></b></td>
     <td width="85%">  <input type="text" name="price" siz
e="4"
                  class="smallinput" maxlength="4"
value="<%=price%>"></td></tr>
     <tr> <td width="15%" align=right> <b><font color="#0080C0">discounted
price :</font></b></td>
      <td width="85%"> <input type="text" name="disprice" size="4"
                  class="smallinput" maxlength="4"
value="<%=dis_price%>"></td>
              </tr>
     <tr> <td width="15%" align=right> <b><font color="#0080C0">hit
:</font></b></td>
      <td width="85%"> <input type="text" name="hit" size="6"
                  class="smallinput" maxlength="6" value="<%=hit%>"></td>
              </tr>
              <tr>
                <td width="15%" align="right" valign="top"><b><font
color="#0080C0">產品內容:</font><br>
                  <font color="#FF0000" size="3">*</font> </b></td>
                <td width="85%">
                  <textarea rows="15" name="content" cols="70"
class="smallarea">
<%=content%></textarea>
                </td>
              </tr>
              <tr>
                <td width="15%" align="right" valign="top" height="20"></td>
                <td width="85%">
                  <input type="hidden" name="origtyp" value="<%=origtyp%>">
                </td>
              </tr>
            </table>
      </td>
    </tr>
  </table>
      <table width="600" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><img src="../IMAGES/bian.gif" width="600" height="13"></td>
        </tr>
      </table>
      <p>
        <input type="submit" value=" 修 改 "
  name="modify" class="buttonface">
        &nbsp;&nbsp;&nbsp;&nbsp;
        <input type="reset" value=" 復 原 "
  name="cancel" class="buttonface">
      </p>
    </center>
  </div>
  <div align="center">
    <center>
    </center></div>
</form>
<div align="center">
  <p>以� 代 <font color="#FF0000" size="3">*</font> 為必填寫</p>
  <p><a href="prod_admin.jsp"><font face="Webdings" size="4">7</font>返回管
理� �面</a> </p>
</div>
</body>
</html>






----- Original Message -----
From: "Anthony Tagunov" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 29, 2001 6:58 PM
Subject: Re: Cannot read file: ze file


> Hello yilmaz,
>
> Thursday, November 29, 2001, 12:08:33 PM, you wrote:
>
> y> Thanks Anthony,
> y> below is the header of my troublesome jsp page.
>
> y> <%@  page language="java" contentType="text/html; charset=utf-8" %>
> Sorry, about my idea with utf8 instead of utf-8 - the iana registry
> has utf-8 not utf8.
> y> <%@ page
> y>
import="java.sql.*,java.text.DateFormat,java.lang.Math,java.util.*,com.oreil
> ly.servlet.*"%>
>
> y> when charset is set to big5 , there is no problem.
> y> Since my OS is Win 2000 traditional chinese, its default charset is
big5,
> y> so  i didn't need a special editor for big5 charset.
> y> Now you say, to set charset to utf8 i need a utf8 specific editor?
> y> i didn't hear this before?
> Yes, this is my reading of the jsp 1.1 spec.
> On page 47 it says:
>
> contentType Defines the character encoding for the JSP page and for the
response
>             of the JSP page and the MIME type for the response of the JSP
page.
> y> can you please make it clearer?
> I say that the encoding of the .jsp file should be exactly the one
> specified as contentType="text/html; charset=xxx", so in your case
> it should be utf-8.
>
> So these files either have to
>  1 - be created with a utf-8 capable editor
> or
>  2 - be coverted from Big5 to utf-8
> y> E.g where can i get it?
> Sorry, i am not an expert at this, but:
>
> Let us consider the two available alternatives
>
>   1 - use a utf-8 capable editor
>
>     I personally use Unicedit by H. Eichmann,
>     it's freeware.
>
>     I do not know if it will work okay with
>     chinese but it might.
>
>     Unfortunantly i can not supply you with a
>     url right now, but i downloaded it from
>     somewhere.
>
>   2 - convert files from Big5 to utf-8
>
>     2.1 - open the file in Big5 encoding
>           and save it in utf-8 encoding by an editor that
>           is capable of both reading Big5 files
>           and saving utf-8 files.
>
>           My version of Unicedit (2.1)
>           does not support reading Big5.
>
>     2.2 - get some program to convert the files
>           from Big5 to utf-8.
>           I can not advise any.
>
>     2.3 - if you're using windows Notepad, then
>           it might work to click the "save as
>           Unicode" checkbox in the "save file"
>           dialog box and then convert your
>           file from Unicode to Utf8.
>           The conversion is very straightforward,
>           maybe you can find some program to do
>           that or write your own. (It shouldn't
>           be difficult to do that say in C)
>
>     2.4 - write your own Java app that does the
>           conversion from Big5 to utf-8.
>           It should be rather easy,
>           as Big5 is supported by Java platform,
>           according to the
>           <jdk-docs>/guide/intl/encoding.doc.html
>
>           All you have to do is
>
>           import java.io.*;
>
>           public class Convert{
>             public static void Main( String args[] ){
>               Reader r =
>                 new InputStreamReader(
>                   new FileInputStream( args[0] ),
>                  "Big5"
>                 );
>               Writer w =
>                 new OutputStreamWriter(
>                   new FileOutputStream( args[1] ),
>                  "utf-8"
>                 );
>               char c[] = new char[256];
>               int cnt;
>               while( (cnt = r.read( c )) > 0) w.write(c);
>             }
>           }
>
>           I haven't tested this, but it should be smth like this
>
>     2.5 - use Ant task to do the conversion.
>           As far as understand currently none of the Ant
>           tasks does this.
>
> PEOPLE, PLEASE CORRECT ME IF I AM WRONG, IS THERE AN ANT TASK
> TO CONVERT THE ENCODING?
>
>           Maybe this should be better discussed in the Ant
>           mail list at jakarta.apache.org.
>
>           Anyway, it shouldn't be _too_ difficult to
>           develop a new Ant task to do that, maybe
>           the <copy> task should be modified into
>           the new one.
>
>           I think this is a usefull functionality
>           so maybe you should ask people on the Ant
>           mail list if anyone has already developed such.
>
> y> thanks  a lot in advance
> You're welcome :-)
> y> cheers :)
> Same here!
>
> Anthony Tagunov
> mailto:[EMAIL PROTECTED]
> mailto:[EMAIL PROTECTED]
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://archives.java.sun.com/jsp-interest.html
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.jsp
>  http://www.jguru.com/faq/index.jsp
>  http://www.jspinsider.com
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to