Dear Filip,
That solves it, many many thanks.
Just a comment if others went into same problem:
* request.setCharacterEncoding("ISO-8859-1"); does not solve the problem
* getBytes() is not deprecated, it uses the platform's default charset instead.
Thanks again,
Ahmed Ashour
Filip Hanik - Dev Lists <devlists@(protected):
getBytes() is deprecated for the reason that different VMs/OSs have
different default encoding.
could that be the cause of your problem?
what if you try getBytes("ISO-8859-1") on both platforms, do you still
get diff results?
Filip
Ahmed Ashour wrote:
> Dear all,
>
> I think something is wrong with parsing parameters for get requests with binary encoding, although request.getCharacterEncoding() is null, the output is different in red hat linux, consider the following test case:
>
> ------------ Servlet code ------------
> protected void doGet(HttpServletRequest request, HttpServletResponse res) throws ServletException, IOException {
> System.out.println( "Query String is " + request.getQueryString() );
> String text = request.getParameter( "text" );
> for( byte b : text.getBytes() )
> System.out.print( "0x" + Integer.toHexString( b ) + ' ' );
> }
>
> ------------ client code ------------
> get( "http://host:port/app/servletname?text=%24%F6%10%30%00" );
>
> private static String get(String url) throws IOException {
> try {
>
> URL _url = new URL(url);
> InputStream _is = _url.openStream();
> int length = _is.available();
> byte[] _out = new byte[length];
> _is.read(_out, 0, length);
> _is.close();
> return new String(_out);
> } catch (Exception e) {}
> return null;
> }
>
> ------------ end of code ------------
> Windows Output:
>
> Query String is text=%24%F6%10%30%00
> 0x24 0xfffffff6 0x10 0x30 0x0
>
> Linux output:
> Query String is text=%24%F6%10%30%00
> 0x24 0xffffffc3 0xffffffb6 0x10 0x30 0x0
>
>
> version used is:
> Using CATALINA_BASE: /usr/tomcat
> Using CATALINA_HOME: /usr/tomcat
> Using CATALINA_TMPDIR: /usr/tomcat/temp
> Using JRE_HOME: /usr/java/jdk1.5.0_06
> Server version: Apache Tomcat/5.5.16
> Server built: Mar 4 2006 08:22:29
> Server number: 5.5.16.0
> OS Name: Linux
> OS Version: 2.4.21-32.0.1.ELsmp
> Architecture: i386
> JVM Version: 1.5.0_06-b05
> JVM Vendor: Sun Microsystems Inc.
>
> What do you think the reason for this discripancy?
>
> Many thanks in advance,
>
> Yours,
> Ahmed Ashour
>
>
> ---------------------------------
> Yahoo! Mail
> Bring photos to life! New PhotoMail makes sharing a breeze.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)
---------------------------------
Yahoo! Mail
Use Photomail to share photos without annoying attachments.