Re: Problems with utf-8 encoding
On 9/19/05, Yair Zohar <[EMAIL PROTECTED]> wrote: > > Hello, > I'm using Tomcat 4.1.18 > I'm trying to read hebrew data in utf-8 encoding from the database. As a > check I entered a utf-8 encoded 'alef' letter to the database field. > (I see it in the database as one letter 'alef'). The jsp page that > displays the data, prints two chars instead of one. I checked the values > of these chars and > they are 215 114, which are the utf-8 combination to create the letter > 'alef' (so I was told). > > jps code: > > <%@ page language="java" contentType="text/html;charset=UTF-8" > pageEncoding="UTF-8" info="Tables Handler" import="tablesHandler.*" %> > > > > > <% request.setCharacterEncoding("UTF-8");%> > > > > > > > Move <% request.setCharacterEncoding("UTF-8");%> to before jsp:useBean tag. -- rgds Anto Paul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problems with utf-8 encoding
Anto Paul wrote: On 9/19/05, Yair Zohar <[EMAIL PROTECTED]> wrote: Hello, I'm using Tomcat 4.1.18 I'm trying to read hebrew data in utf-8 encoding from the database. As a check I entered a utf-8 encoded 'alef' letter to the database field. (I see it in the database as one letter 'alef'). The jsp page that displays the data, prints two chars instead of one. I checked the values of these chars and they are 215 114, which are the utf-8 combination to create the letter 'alef' (so I was told). jps code: <%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" info="Tables Handler" import="tablesHandler.*" %> <% request.setCharacterEncoding("UTF-8");%> Move <% request.setCharacterEncoding("UTF-8");%> to before jsp:useBean tag. Thanks for replying, It didn't fix the problem, I still see the same two chars. Yair.
Re: Problems with utf-8 encoding
Does your browser supports hebrew ?. If you are just getting the data from database and displaying, it should work fine. What database and JDBC driver you are using ?. On 9/19/05, Yair Zohar <[EMAIL PROTECTED]> wrote: > Anto Paul wrote: > > >On 9/19/05, Yair Zohar <[EMAIL PROTECTED]> wrote: > > > > > >>Hello, > >>I'm using Tomcat 4.1.18 > >>I'm trying to read hebrew data in utf-8 encoding from the database. As a > >>check I entered a utf-8 encoded 'alef' letter to the database field. > >>(I see it in the database as one letter 'alef'). The jsp page that > >>displays the data, prints two chars instead of one. I checked the values > >>of these chars and > >>they are 215 114, which are the utf-8 combination to create the letter > >>'alef' (so I was told). > >> > >>jps code: > >> > >><%@ page language="java" contentType="text/html;charset=UTF-8" > >>pageEncoding="UTF-8" info="Tables Handler" import="tablesHandler.*" %> > >> > >> > >> > >> > >><% request.setCharacterEncoding("UTF-8");%> > >> > >> > >> > >> > >> > >> > >> > >> > >> > > > >Move <% request.setCharacterEncoding("UTF-8");%> to before jsp:useBean tag. > > > > > > > Thanks for replying, > It didn't fix the problem, I still see the same two chars. > Yair. > > > -- rgds Anto Paul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Problems with utf-8 encoding
put an encoding filter in front of your servlet/jsp's that sets a UTF-8 encoding for incoming requests and outgoing responses. its your safest bet for tomcat 4 as far as i remember. -Original Message- From: Yair Zohar [mailto:[EMAIL PROTECTED] Sent: Monday, September 19, 2005 9:43 AM To: Tomcat Users List Subject: Re: Problems with utf-8 encoding Anto Paul wrote: >On 9/19/05, Yair Zohar <[EMAIL PROTECTED]> wrote: > > >>Hello, >>I'm using Tomcat 4.1.18 >>I'm trying to read hebrew data in utf-8 encoding from the database. As a >>check I entered a utf-8 encoded 'alef' letter to the database field. >>(I see it in the database as one letter 'alef'). The jsp page that >>displays the data, prints two chars instead of one. I checked the values >>of these chars and >>they are 215 114, which are the utf-8 combination to create the letter >>'alef' (so I was told). >> >>jps code: >> >><%@ page language="java" contentType="text/html;charset=UTF-8" >>pageEncoding="UTF-8" info="Tables Handler" import="tablesHandler.*" %> >> >> >> >> >><% request.setCharacterEncoding("UTF-8");%> >> >> >> >> >> >> >> >> >> > >Move <% request.setCharacterEncoding("UTF-8");%> to before jsp:useBean tag. > > > Thanks for replying, It didn't fix the problem, I still see the same two chars. Yair. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problems with utf-8 encoding
Guy Katz wrote: put an encoding filter in front of your servlet/jsp's that sets a UTF-8 encoding for incoming requests and outgoing responses. its your safest bet for tomcat 4 as far as i remember. -Original Message- From: Yair Zohar [mailto:[EMAIL PROTECTED] Sent: Monday, September 19, 2005 9:43 AM To: Tomcat Users List Subject: Re: Problems with utf-8 encoding Anto Paul wrote: On 9/19/05, Yair Zohar <[EMAIL PROTECTED]> wrote: Hello, I'm using Tomcat 4.1.18 I'm trying to read hebrew data in utf-8 encoding from the database. As a check I entered a utf-8 encoded 'alef' letter to the database field. (I see it in the database as one letter 'alef'). The jsp page that displays the data, prints two chars instead of one. I checked the values of these chars and they are 215 114, which are the utf-8 combination to create the letter 'alef' (so I was told). jps code: <%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" info="Tables Handler" import="tablesHandler.*" %> <% request.setCharacterEncoding("UTF-8");%> Move <% request.setCharacterEncoding("UTF-8");%> to before jsp:useBean tag. Thanks for replying, It didn't fix the problem, I still see the same two chars. Yair. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Guy, can you direct me to practical documentation on implementing such a filter ?
RE: Problems with utf-8 encoding
google it. there's a lot. -Original Message- From: Yair Zohar [mailto:[EMAIL PROTECTED] Sent: Monday, September 19, 2005 11:08 AM To: Tomcat Users List Subject: Re: Problems with utf-8 encoding Guy Katz wrote: >put an encoding filter in front of your servlet/jsp's that sets a UTF-8 >encoding for incoming requests and outgoing responses. its your safest bet for >tomcat 4 as far as i remember. > >-Original Message- >From: Yair Zohar [mailto:[EMAIL PROTECTED] >Sent: Monday, September 19, 2005 9:43 AM >To: Tomcat Users List >Subject: Re: Problems with utf-8 encoding > > >Anto Paul wrote: > > > >>On 9/19/05, Yair Zohar <[EMAIL PROTECTED]> wrote: >> >> >> >> >>>Hello, >>>I'm using Tomcat 4.1.18 >>>I'm trying to read hebrew data in utf-8 encoding from the database. As a >>>check I entered a utf-8 encoded 'alef' letter to the database field. >>>(I see it in the database as one letter 'alef'). The jsp page that >>>displays the data, prints two chars instead of one. I checked the values >>>of these chars and >>>they are 215 114, which are the utf-8 combination to create the letter >>>'alef' (so I was told). >>> >>>jps code: >>> >>><%@ page language="java" contentType="text/html;charset=UTF-8" >>>pageEncoding="UTF-8" info="Tables Handler" import="tablesHandler.*" %> >>> >>> >>> >>> >>><% request.setCharacterEncoding("UTF-8");%> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>Move <% request.setCharacterEncoding("UTF-8");%> to before jsp:useBean tag. >> >> >> >> >> >Thanks for replying, >It didn't fix the problem, I still see the same two chars. >Yair. > > >- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > > > > > Guy, can you direct me to practical documentation on implementing such a filter ? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problems with utf-8 encoding
Guy Katz wrote: google it. there's a lot. -Original Message- From: Yair Zohar [mailto:[EMAIL PROTECTED] Sent: Monday, September 19, 2005 11:08 AM To: Tomcat Users List Subject: Re: Problems with utf-8 encoding Guy Katz wrote: put an encoding filter in front of your servlet/jsp's that sets a UTF-8 encoding for incoming requests and outgoing responses. its your safest bet for tomcat 4 as far as i remember. -Original Message- From: Yair Zohar [mailto:[EMAIL PROTECTED] Sent: Monday, September 19, 2005 9:43 AM To: Tomcat Users List Subject: Re: Problems with utf-8 encoding Anto Paul wrote: On 9/19/05, Yair Zohar <[EMAIL PROTECTED]> wrote: Hello, I'm using Tomcat 4.1.18 I'm trying to read hebrew data in utf-8 encoding from the database. As a check I entered a utf-8 encoded 'alef' letter to the database field. (I see it in the database as one letter 'alef'). The jsp page that displays the data, prints two chars instead of one. I checked the values of these chars and they are 215 114, which are the utf-8 combination to create the letter 'alef' (so I was told). jps code: <%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" info="Tables Handler" import="tablesHandler.*" %> <% request.setCharacterEncoding("UTF-8");%> Move <% request.setCharacterEncoding("UTF-8");%> to before jsp:useBean tag. Thanks for replying, It didn't fix the problem, I still see the same two chars. Yair. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Guy, can you direct me to practical documentation on implementing such a filter ? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Hi again, I implemented the SetCharacterEncodingFilter from the tomcat 4 examples, In order to check the control I have on the character encoding of the request and response I changed the doFilter method to be: public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { request.setCharacterEncoding("UTF-8"); System.out.println("Request: "+request.getCharacterEncoding()); response.setContentType("text/html; charset=UTF-8"); System.out.println("Response: "+response.getCharacterEncoding()); // Pass control on to the next filter chain.doFilter(request, response); } request.getCharacterEncoding() returns null. It also returns null if I put the request.setCharacterEncoding("UTF-8"); as a remark. (my page contains utf-8 encoding directives). The response however is set to UTF-8. Can this explain my problem using UTF-8 encoding ? Does anybody know how to solve it ?
Re: Problems with utf-8 encoding
Yair Zohar wrote: Guy Katz wrote: google it. there's a lot. -Original Message- From: Yair Zohar [mailto:[EMAIL PROTECTED] Sent: Monday, September 19, 2005 11:08 AM To: Tomcat Users List Subject: Re: Problems with utf-8 encoding Guy Katz wrote: put an encoding filter in front of your servlet/jsp's that sets a UTF-8 encoding for incoming requests and outgoing responses. its your safest bet for tomcat 4 as far as i remember. -Original Message- From: Yair Zohar [mailto:[EMAIL PROTECTED] Sent: Monday, September 19, 2005 9:43 AM To: Tomcat Users List Subject: Re: Problems with utf-8 encoding Anto Paul wrote: On 9/19/05, Yair Zohar <[EMAIL PROTECTED]> wrote: Hello, I'm using Tomcat 4.1.18 I'm trying to read hebrew data in utf-8 encoding from the database. As a check I entered a utf-8 encoded 'alef' letter to the database field. (I see it in the database as one letter 'alef'). The jsp page that displays the data, prints two chars instead of one. I checked the values of these chars and they are 215 114, which are the utf-8 combination to create the letter 'alef' (so I was told). jps code: <%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" info="Tables Handler" import="tablesHandler.*" %> class="tablesHandler.TableViewer" /> <% request.setCharacterEncoding("UTF-8");%> Move <% request.setCharacterEncoding("UTF-8");%> to before jsp:useBean tag. Thanks for replying, It didn't fix the problem, I still see the same two chars. Yair. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Guy, can you direct me to practical documentation on implementing such a filter ? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Hi again, I implemented the SetCharacterEncodingFilter from the tomcat 4 examples, In order to check the control I have on the character encoding of the request and response I changed the doFilter method to be: public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { request.setCharacterEncoding("UTF-8"); System.out.println("Request: "+request.getCharacterEncoding()); response.setContentType("text/html; charset=UTF-8"); System.out.println("Response: "+response.getCharacterEncoding()); // Pass control on to the next filter chain.doFilter(request, response); } request.getCharacterEncoding() returns null. It also returns null if I put the request.setCharacterEncoding("UTF-8"); as a remark. (my page contains utf-8 encoding directives). The response however is set to UTF-8. Can this explain my problem using UTF-8 encoding ? Does anybody know how to solve it ? The filter does the work, it solved the problem. Thanks all who helped, Yair. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problems with utf-8 encoding - continue
Why aren't you using setContentType("text/html, "utf-8") on the response? What content-type is the server actually returning (use the live http headers extension for firefox or something similar to find out). What database and jdbc driver are you using? What method are you using to store the string in the database? I've had utf-8 trouble with several databases. For example mysql 4.1 + the latest jdbc driver + setCharacterStream had some strange effects. First of all you need to tell mysql to use utf-8 (it defaults to something else) and even if you do that setCharacterStream has some issues that go away if you use setString. Oracle on the other hand cannot insert strings larger than 4KB with setString so you need to use setCharacterStream. Incidently, the mysql driver implementation of setCharacterString is implemented using setString! Regards, Jilles Yair Zohar wrote: sorry for the double mail, I forgot to add my server.xml encoding definitions: port="8080" URIEncoding="UTF-8" useBodyEncodingForURI="true" minProcessors="5" maxProcessors="75" enableLookups="true" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="2" useURIValidationHack="false" disableUploadTimeout="true" /> I tried it with and without the useBodyEncodingForURI="true"directive. Yair. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problems with utf-8 encoding - continue
Jilles van Gurp wrote: Oracle on the other hand cannot insert strings larger than 4KB with setString so you need to use setCharacterStream. FYI: This is "common knowledge" that used to be right, but isn't anymore. With the Oracle 10g JDBC driver you can set arbitrary length strings with setString http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/clob10g/handlingclobsinoraclejdbc10g.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problems with utf-8 encoding - continue
Jilles van Gurp wrote: Why aren't you using setContentType("text/html, "utf-8") on the response? As I use jsp, I don't know how can I control the response that way. What content-type is the server actually returning (use the live http headers extension for firefox or something similar to find out). I couldn't find if this extension is installed, or how to install it. In the page info : Type: text/html Encoding: UTF-8 Meta: Content-Type text/html; charset=UTF-8 What database and jdbc driver are you using? What method are you using to store the string in the database? I use mysql 4.1.14 + connector 3.1.10 the url for the driver is: "jdbc:mysql://"+Utils.getServerName()+":3306/"+Utils.getDatabaseName()+"?characterEncoding=UTF-8&characterSetResults=UTF-8" the tables definitions: ENGINE=MyISAM DEFAULT CHARSET=utf8 I've had utf-8 trouble with several databases. For example mysql 4.1 + the latest jdbc driver + setCharacterStream had some strange effects. First of all you need to tell mysql to use utf-8 (it defaults to something else) and even if you do that setCharacterStream has some issues that go away if you use setString. Oracle on the other hand cannot insert strings larger than 4KB with setString so you need to use setCharacterStream. Incidently, the mysql driver implementation of setCharacterString is implemented using setString! I use Statement class executeUpdate(String str) method to update and executeQuery(String str) to query the database. Regards, Jilles Yair Zohar wrote: sorry for the double mail, I forgot to add my server.xml encoding definitions: port="8080" URIEncoding="UTF-8" useBodyEncodingForURI="true" minProcessors="5" maxProcessors="75" enableLookups="true" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="2" useURIValidationHack="false" disableUploadTimeout="true" /> I tried it with and without the useBodyEncodingForURI="true"directive. Yair. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]