RE: [Fwd: Re: Servlet on Tomcat + Oracle +ISU 8859-8 (Hebrew Char Set)- encodin g problem]

2004-03-31 Thread yair . fine
Thanks Veniamin Fichin,
Can you copy paste your code that solves the problem?
Regards 
Yair Fine
-Original Message-
From: Veniamin Fichin [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 31, 2004 2:20 PM
To: [EMAIL PROTECTED]
Subject: [Fwd: Re: Servlet on Tomcat + Oracle +ISU 8859-8 (Hebrew CharSet)-
encodin g problem]


Some fixes to WAR file posted recently. Now POST methods all work 
fine, but none of GET.

 Original Message 
Subject: Re: Servlet on Tomcat + Oracle +ISU 8859-8 (Hebrew CharSet) - 
encodin g problem
Date: Wed, 31 Mar 2004 14:34:27 +0400
From: Veniamin Fichin [EMAIL PROTECTED]
Reply-To: Tomcat Users List [EMAIL PROTECTED]
To: Tomcat Users List [EMAIL PROTECTED]
References: [EMAIL PROTECTED]

This is my problem also, and sadly it's so since long time I use Tomcat.

 I've attach a simple little test case .war file to reproduce the
problem. There are four HTML forms there, two of them submits to JSP page
(GET and POST methods), others go to servlet (same methods).
 On top of it is a select field allowing to define an encoding for
future submits. It acts as following: after choosing it and submitting that
select the JSP page is reloaded with that encoding, setting its
response.setContentType() and setting session attribute named tHAVW07QUf
(for uniqueness, see below). Now, one can submit any form presented below.
 I've deployed a filter.SetCharacterEncodingFilter (taken from standard
Tomcat distribution), with one modification: during every request it reads
session attribute tHAVW07QUf and sets requests' encoding accordingly. If
that attribute is absent, it reads its init parameter given in web.xml as
usually. So, instead of hard-coding character incoding in web.xml, I can set
it online. According to filters.RequestDumperFilter (also Tomcat's standard
filter) it works.
 So, let's see what we have here. The result on my machine is that any
GET methods produces broken output of the parameter passed as URL-encoded
%XX%XX%XX string, actual encoding of which is set by select box on the first
page. Any combinations of encoding, submit methods and target actions (JSP
or Servlet) give me broken output, except two of them -- utf-8 POST to JSP
and utf-8 POST to Servlet.
 I looked at Tomcat's some source files, namely
org.apache.catalina.util.RequestUtil.URLDecode(byte[], String) and
org.apache.catalina.util.RequestUtil.parseParameters(java.util.Map,
byte[], String), and see how url-encoded request parameters are parsed, but
I don't know if it's the right place to see.
 Ah, and one note. I tried to run Tomcat with -Dfile.encoding=koi8-r
option to set default byte[]-String conversion mapping to koi8-r (for
example), and even this does not help me much, though it sets the new
default.
 This behaviour was there on 4.x and 5.x versions, seems like nothing is
changing.

 I don't state that I've done all tests correctly, so in any error
please fix my mind. The only question is: how one can universally and
correctly handle non-ASCII request parameters and get rightly decoded
output?

[EMAIL PROTECTED] wrote:

 Hi all ,
 i have a problem with encoding and decoding, from a servlet , running 
 on Tomcat , to Oracle DB. I hope it is the right forum for that , and 
 i appologize if ti is not ..
  
 The problem:
 I am using Oracle 8.1.7 DB , in a Charest ISU 8859-9-8 ( Hebrew ), I 
 use a thin client as the JDBC driver . I have a servlet that all it 
 does is getting and updating one of the table
  
 The character set in the servlet is too , ISO 8859-8 . This is done 
 this
 way:
  
 public void doGet(HttpServletRequest request, HttpServletResponse
response)
   throws ServletException, IOException {
   
   request.setCharacterEncoding(ISO-8859-8);
   response.setContentType(Text/html; ISO-8859-8);
   .
 }
 
 I  use the doGet method of a servlet to get parameters to retrieve 
 from Oracle. this is done through the URL, for example : I send the 
 parameters like this : http://localhost:8080/myapp/myapp?name=yair
 http://localhost:8080/myapp/myapp?name=yairfamily=fine family=fine
 for name= yair, family = fine
  
 There is no problem in getting and inserting English characters. There 
 is a problem when i try to get or to insert Hebrew characters. i get 
  in DB , for both if i write yair in the url in Hebrew , or i 
 write yair in %E9%E9%E9%F8 which is the decimal representation
  
 For example , if i insert a string in Hebrew , it looks like this 
 ? ( in SQL +)
 
 this is how i get the requests from the url
 Enumeration paramEnum = request.getParameterNames(); // get request 
 parameters from the url , in param/value pairs String myParam = 
 (String) paramEnum.nextElement(); //get parameter String myValue = 
 request.getParameter(myParam);  //get value
  
 String myStatment = insert into mytable values('19', '+myValue+') 
 insert to table 19 , myvalue ResultSet rs = 
 stmt.executeQuery(myStatment);
  
 does any one have a solution for that ?




Re: [Fwd: Re: Servlet on Tomcat + Oracle +ISU 8859-8 (Hebrew Char Set)- encodin g problem]

2004-03-31 Thread Veniamin Fichin
[EMAIL PROTECTED] wrote:

Thanks Veniamin Fichin,
Can you copy paste your code that solves the problem?
   The output encoding of view.jsp page was hard-coded utf-8 value. I 
changed it to be more flexible by lookling into session attribute which 
was set previously. Code snipped follows.

--- view.jsp: ---

%
String encoding=(String)session.getAttribute(tHAVW07QUf);
if (session!=null) {
response.setContentType(text/html; charset=+encoding);
}
%
%@ page pageEncoding=utf-8 info=Test: localized parameters%
!-- ... JSP body ... --
--- / view.jsp: ---

   Session attribute setting you can see in source code. But bear in 
mind that this fix works with POST method only (at least for me).

Regards 
Yair Fine
2all: have anybody interested in this topic tried that .war? What's the 
results?



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]