You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Bilge Erkan <bi...@polar.biz.tr> on 2004/02/25 11:53:30 UTC

International character problem in submitting a jsp form

Hi,

I'm using Tomcat 4.1.12. I have a trouble using Turkish characters in
inputs on my forms. I don't have any problem displaying constant strings
from resource files or displaying data retrieved from database where 
they both contain Turkish characters.

So I decided to make a simple test as follows:

I have a form with a text input in a jsp page. I post this form to
another jsp page and this page just prints this parameter value to
'out'. As a result Turkish characters are not displayed correctly.

The following is the jsp that has the form:

<%@ page language="java" contentType="text/html;charset=utf-8"
session="true"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
</head>
<body>
<form method="POST" name="Test" action="PostTest2.jsp">
     <input type="text" name="data">
     <input type="submit" name="buttonSubmit" value="OK">
</form>

</body>
</html>


The following is the jsp that the form is posted:

<%@ page language="java" contentType="text/html;charset=utf-8"
session="true"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
</head>
<body>
<%
     out.println(response.getCharacterEncoding());
     out.println(response.getLocale());
     out.println(request.getCharacterEncoding());
     out.println(request.getLocale());

     String s = request.getParameter("data");
     out.println(s);
     System.out.println(s);
%>

</body>
</html>


The output is as follows:

utf-8 en_US null tr Ä?üÅ?ıöçÄ?Ã?Å?Ä°Ã?Ã?

Here, the character encoding of the response seems to be utf-8, the
locale of the response seems to be en_US, the character encoding of the
request seems to be null (maybe the problem is here, but I don't know
how to solve) and the locale of the request seems to be tr.

I also tried to set charset to iso-8859-9 which is for Turkish
characters, instead of utf-8, but the problem is same. The output is as
follows:

iso-8859-9 en_US null tr ?ü??öç?Ü??ÖÇ


How can I solve this problem? Are there any settings to give to Tomcat?
How does Tomcat determine the locale of the server?

PS: I later tried to use Tomcat 4.1.30, and everything is same. 4.1.12
version that I'm using was an rpm installation and it has a tomcat.conf
file, in which there is a LANG parameter that I set it to tr_TR. But it
does not solve this problem. In 4.1.30 version there is no such a file
to set LANG. How can we make LANG setting in 4.1.30?


Thanks a lot,
Bilge


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: International character problem in submitting a jsp form

Posted by Scott Farquhar <sc...@atlassian.com>.
On Wed, Feb 25, 2004 at 07:32:04PM +0200, Metin Zavrak wrote:
> > The output is as follows:
> >
> > utf-8 en_US null tr Ä?üÅ?ıöçÄ?Ã?Å?Ä°Ã?Ã?

What operating System are you using?  I believe that Windows doesn't have
a UTF-8 aware system terminal.

Try using linux instead for a UTF terminal.

Else write it to a file.

I use Tomcat with JIRA[1] and have no problems with i18n.

Cheers,
Scott

[1] - http://jira.atlassian.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Using HTTPS with keystore and trust store files

Posted by Alex Chen <ac...@packetmotion.com>.
Thanks, Rommel,

Rommel Sharma wrote:

>What I can say is this:
>1. In keystoreFile attribute provide the complete path
>(C:\MyCertFolder\mykeystore.ks)
>    Same for truststore.
>
>2. Where do I specify the file that store the client's certificate?
>In your client code that makes a call to the https specify the location of
>the keystore and in the server side code that you will will write, get the
>message context
>(someting like:
>  MessageContext context = MessageContext.getCurrentContext();
>  ...
>  HttpServletRequest req = (HttpServletRequest)context .getProperty
>(HTTPConstants.MC_HTTP_SERVLETREQUEST);
>
> // and the code to match the client certificate with the client keystore on
>the server
>// so you specify its location on the server having the same client
>keystore...
>)
>
>Hope this helps,
>Regards,
>Rommel.
>
>----- Original Message -----
>From: "Alex Chen" <ac...@packetmotion.com>
>To: "Tomcat Users List" <to...@jakarta.apache.org>
>Sent: Wednesday, February 25, 2004 11:30 PM
>Subject: Using HTTPS with keystore and trust store files
>
>  
>
>>Hi,
>>  I am trying to set up Tomcat for HTTPS connection with keystore and
>>truststore files.  I want to use Tomcat as the
>>web server so the port number is 80 and 443 for HTTP and HTTPS,
>>respectively. I am running Tomcat on Windows XP.
>>
>>Here is the 'Connector' entry in %CATALINA_HOME%\conf\server.xml.
>>   <Connector port="443"
>>               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
>>               enableLookups="false" disableUploadTimeout="true"
>>               acceptCount="100" debug="0" scheme="https" secure="true"
>>               clientAuth="true" sslProtocol="TLS"
>>               keystoreFile="server.ks" keystoreType="JCEKS"
>>               keystorePass="changeit"
>>               truststoreFile="server.ts" truststoreType="JCEKS" >
>>    </Connector>
>>
>>When I start tomcat, I get the following error:
>>
>>java.io.FileNotFoundException: server.ks (The system cannot find the
>>file specif
>>ied)
>>        at java.io.FileInputStream.open(Native Method)
>>        at java.io.FileInputStream.<init>(FileInputStream.java:106)
>>        at java.io.FileInputStream.<init>(FileInputStream.java:66)
>>        at
>>org.apache.tomcat.util.net.jsse.JSSESocketFactory.getStore(JSSESocket
>>Factory.java:262)
>>        at
>>org.apache.tomcat.util.net.jsse.JSSESocketFactory.getKeystore(JSSESoc
>>ketFactory.java:232)
>>......
>>
>>I tried to put the file in different places, the user's home directory
>>in C:\Documents and Settings\%user%\,
>>%CATALINA_HOME%\,  %CATALINA_HOME%\webapps, %CATALINA_HOME%\webapps\ROOT,
>>but they all failed.
>>
>>My questions are:
>>1. Where should the keystore file be stored if I set the 'keystoreFile'
>>attribute in Connector element?
>>
>>2.  If I set 'clientAuth' to true, shouldn't there be a place to store
>>the the client's certificate, i.e. the truststore?
>>     Where do I specify the file that store the client's certificate?
>>     I saw the truststoreFile attribute in an example from
>>http://www.j2ee-security.net/book/sample-chap/
>>     It sets this attribute in a 'Factory' subelement.  But that is for
>>Tomcat 4.X.
>>
>>Any help is appreciated.
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>
>>
>>    
>>
>
>*********************************************************
>Disclaimer
>
>This message (including any attachments) contains 
>confidential information intended for a specific 
>individual and purpose, and is protected by law. 
>If you are not the intended recipient, you should 
>delete this message and are hereby notified that 
>any disclosure, copying, or distribution of this
>message, or the taking of any action based on it, 
>is strictly prohibited.
>
>*********************************************************
>Visit us at http://www.mahindrabt.com
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Using HTTPS with keystore and trust store files

Posted by Rommel Sharma <ro...@mahindrabt.com>.
What I can say is this:
1. In keystoreFile attribute provide the complete path
(C:\MyCertFolder\mykeystore.ks)
    Same for truststore.

2. Where do I specify the file that store the client's certificate?
In your client code that makes a call to the https specify the location of
the keystore and in the server side code that you will will write, get the
message context
(someting like:
  MessageContext context = MessageContext.getCurrentContext();
  ...
  HttpServletRequest req = (HttpServletRequest)context .getProperty
(HTTPConstants.MC_HTTP_SERVLETREQUEST);

 // and the code to match the client certificate with the client keystore on
the server
// so you specify its location on the server having the same client
keystore...
)

Hope this helps,
Regards,
Rommel.

----- Original Message -----
From: "Alex Chen" <ac...@packetmotion.com>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Wednesday, February 25, 2004 11:30 PM
Subject: Using HTTPS with keystore and trust store files

> Hi,
>   I am trying to set up Tomcat for HTTPS connection with keystore and
> truststore files.  I want to use Tomcat as the
> web server so the port number is 80 and 443 for HTTP and HTTPS,
> respectively. I am running Tomcat on Windows XP.
>
> Here is the 'Connector' entry in %CATALINA_HOME%\conf\server.xml.
>    <Connector port="443"
>                maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
>                enableLookups="false" disableUploadTimeout="true"
>                acceptCount="100" debug="0" scheme="https" secure="true"
>                clientAuth="true" sslProtocol="TLS"
>                keystoreFile="server.ks" keystoreType="JCEKS"
>                keystorePass="changeit"
>                truststoreFile="server.ts" truststoreType="JCEKS" >
>     </Connector>
>
> When I start tomcat, I get the following error:
>
> java.io.FileNotFoundException: server.ks (The system cannot find the
> file specif
> ied)
>         at java.io.FileInputStream.open(Native Method)
>         at java.io.FileInputStream.<init>(FileInputStream.java:106)
>         at java.io.FileInputStream.<init>(FileInputStream.java:66)
>         at
> org.apache.tomcat.util.net.jsse.JSSESocketFactory.getStore(JSSESocket
> Factory.java:262)
>         at
> org.apache.tomcat.util.net.jsse.JSSESocketFactory.getKeystore(JSSESoc
> ketFactory.java:232)
> ......
>
> I tried to put the file in different places, the user's home directory
> in C:\Documents and Settings\%user%\,
> %CATALINA_HOME%\,  %CATALINA_HOME%\webapps, %CATALINA_HOME%\webapps\ROOT,
> but they all failed.
>
> My questions are:
> 1. Where should the keystore file be stored if I set the 'keystoreFile'
> attribute in Connector element?
>
> 2.  If I set 'clientAuth' to true, shouldn't there be a place to store
> the the client's certificate, i.e. the truststore?
>      Where do I specify the file that store the client's certificate?
>      I saw the truststoreFile attribute in an example from
> http://www.j2ee-security.net/book/sample-chap/
>      It sets this attribute in a 'Factory' subelement.  But that is for
> Tomcat 4.X.
>
> Any help is appreciated.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>

*********************************************************
Disclaimer

This message (including any attachments) contains 
confidential information intended for a specific 
individual and purpose, and is protected by law. 
If you are not the intended recipient, you should 
delete this message and are hereby notified that 
any disclosure, copying, or distribution of this
message, or the taking of any action based on it, 
is strictly prohibited.

*********************************************************
Visit us at http://www.mahindrabt.com




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Using HTTPS with keystore and trust store files

Posted by Alex Chen <ac...@packetmotion.com>.
Hi,
  I am trying to set up Tomcat for HTTPS connection with keystore and 
truststore files.  I want to use Tomcat as the
web server so the port number is 80 and 443 for HTTP and HTTPS, 
respectively. I am running Tomcat on Windows XP.

Here is the 'Connector' entry in %CATALINA_HOME%\conf\server.xml.
   <Connector port="443"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" disableUploadTimeout="true"
               acceptCount="100" debug="0" scheme="https" secure="true"
               clientAuth="true" sslProtocol="TLS"
               keystoreFile="server.ks" keystoreType="JCEKS"
               keystorePass="changeit"
               truststoreFile="server.ts" truststoreType="JCEKS" >
    </Connector>

When I start tomcat, I get the following error:

java.io.FileNotFoundException: server.ks (The system cannot find the 
file specif
ied)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:106)
        at java.io.FileInputStream.<init>(FileInputStream.java:66)
        at 
org.apache.tomcat.util.net.jsse.JSSESocketFactory.getStore(JSSESocket
Factory.java:262)
        at 
org.apache.tomcat.util.net.jsse.JSSESocketFactory.getKeystore(JSSESoc
ketFactory.java:232)
......

I tried to put the file in different places, the user's home directory 
in C:\Documents and Settings\%user%\,
%CATALINA_HOME%\,  %CATALINA_HOME%\webapps, %CATALINA_HOME%\webapps\ROOT,
but they all failed.

My questions are:
1. Where should the keystore file be stored if I set the 'keystoreFile' 
attribute in Connector element?

2.  If I set 'clientAuth' to true, shouldn't there be a place to store 
the the client's certificate, i.e. the truststore?
     Where do I specify the file that store the client's certificate?
     I saw the truststoreFile attribute in an example from 
http://www.j2ee-security.net/book/sample-chap/
     It sets this attribute in a 'Factory' subelement.  But that is for 
Tomcat 4.X.

Any help is appreciated.



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: International character problem in submitting a jsp form

Posted by Metin Zavrak <me...@su.sabanciuniv.edu>.
Hi,
I know it is a nightmare.

We love Java, don't we?
We love Tomcat, don't we?
So what about internalization?

Thanks,



Bilge Erkan wrote:

> Hi,
>
> I'm using Tomcat 4.1.12. I have a trouble using Turkish characters in
> inputs on my forms. I don't have any problem displaying constant strings
> from resource files or displaying data retrieved from database where 
> they both contain Turkish characters.
>
> So I decided to make a simple test as follows:
>
> I have a form with a text input in a jsp page. I post this form to
> another jsp page and this page just prints this parameter value to
> 'out'. As a result Turkish characters are not displayed correctly.
>
> The following is the jsp that has the form:
>
> <%@ page language="java" contentType="text/html;charset=utf-8"
> session="true"%>
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
> </head>
> <body>
> <form method="POST" name="Test" action="PostTest2.jsp">
>     <input type="text" name="data">
>     <input type="submit" name="buttonSubmit" value="OK">
> </form>
>
> </body>
> </html>
>
>
> The following is the jsp that the form is posted:
>
> <%@ page language="java" contentType="text/html;charset=utf-8"
> session="true"%>
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
> </head>
> <body>
> <%
>     out.println(response.getCharacterEncoding());
>     out.println(response.getLocale());
>     out.println(request.getCharacterEncoding());
>     out.println(request.getLocale());
>
>     String s = request.getParameter("data");
>     out.println(s);
>     System.out.println(s);
> %>
>
> </body>
> </html>
>
>
> The output is as follows:
>
> utf-8 en_US null tr Ä?üÅ?ıöçÄ?Ã?Å?Ä°Ã?Ã?
>
> Here, the character encoding of the response seems to be utf-8, the
> locale of the response seems to be en_US, the character encoding of the
> request seems to be null (maybe the problem is here, but I don't know
> how to solve) and the locale of the request seems to be tr.
>
> I also tried to set charset to iso-8859-9 which is for Turkish
> characters, instead of utf-8, but the problem is same. The output is as
> follows:
>
> iso-8859-9 en_US null tr ?ü??öç?Ü??ÖÇ
>
>
> How can I solve this problem? Are there any settings to give to Tomcat?
> How does Tomcat determine the locale of the server?
>
> PS: I later tried to use Tomcat 4.1.30, and everything is same. 4.1.12
> version that I'm using was an rpm installation and it has a tomcat.conf
> file, in which there is a LANG parameter that I set it to tr_TR. But it
> does not solve this problem. In 4.1.30 version there is no such a file
> to set LANG. How can we make LANG setting in 4.1.30?
>
>
> Thanks a lot,
> Bilge
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: International character problem in submitting a jsp form

Posted by Bilge Erkan <bi...@polar.biz.tr>.
Thanks for the answers. I found my solution. I found very good hints 
from the following link.

http://marc.theaimsgroup.com/?l=tomcat-user&m=105532850031181&w=2
that I have reached from
http://jakarta.apache.org/tomcat/faq/misc.html#utf8

The conversion explained in that link is really needed.

Now I have Turkish characters working with the following configuration. 
Hope it helps to others who have similar problems.

MySQL 4.0.16 (default_char_set=latin5)
MySQL jdbc driver 3.0.7-stable (Turkish characters have problems with 
previous versions, I have tried some 2.0 versions)
Java J2SDK 1.4.1
Tomcat 4.1.30 (Set charset ISO-8859-9 in JSP pages and convert posted 
strings to ISO-8859-9 as mentioned in the above link)

Bilge

---

Bilge Erkan wrote:
> Hi,
> 
> I'm using Tomcat 4.1.12. I have a trouble using Turkish characters in
> inputs on my forms. I don't have any problem displaying constant strings
> from resource files or displaying data retrieved from database where 
> they both contain Turkish characters.
> 
> So I decided to make a simple test as follows:
> 
> I have a form with a text input in a jsp page. I post this form to
> another jsp page and this page just prints this parameter value to
> 'out'. As a result Turkish characters are not displayed correctly.
> 
> The following is the jsp that has the form:
> 
> <%@ page language="java" contentType="text/html;charset=utf-8"
> session="true"%>
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
> </head>
> <body>
> <form method="POST" name="Test" action="PostTest2.jsp">
>     <input type="text" name="data">
>     <input type="submit" name="buttonSubmit" value="OK">
> </form>
> 
> </body>
> </html>
> 
> 
> The following is the jsp that the form is posted:
> 
> <%@ page language="java" contentType="text/html;charset=utf-8"
> session="true"%>
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
> </head>
> <body>
> <%
>     out.println(response.getCharacterEncoding());
>     out.println(response.getLocale());
>     out.println(request.getCharacterEncoding());
>     out.println(request.getLocale());
> 
>     String s = request.getParameter("data");
>     out.println(s);
>     System.out.println(s);
> %>
> 
> </body>
> </html>
> 
> 
> The output is as follows:
> 
> utf-8 en_US null tr Ä?üÅ?ıöçÄ?Ã?Å?Ä°Ã?Ã?
> 
> Here, the character encoding of the response seems to be utf-8, the
> locale of the response seems to be en_US, the character encoding of the
> request seems to be null (maybe the problem is here, but I don't know
> how to solve) and the locale of the request seems to be tr.
> 
> I also tried to set charset to iso-8859-9 which is for Turkish
> characters, instead of utf-8, but the problem is same. The output is as
> follows:
> 
> iso-8859-9 en_US null tr ?ü??öç?Ü??ÖÇ
> 
> 
> How can I solve this problem? Are there any settings to give to Tomcat?
> How does Tomcat determine the locale of the server?
> 
> PS: I later tried to use Tomcat 4.1.30, and everything is same. 4.1.12
> version that I'm using was an rpm installation and it has a tomcat.conf
> file, in which there is a LANG parameter that I set it to tr_TR. But it
> does not solve this problem. In 4.1.30 version there is no such a file
> to set LANG. How can we make LANG setting in 4.1.30?
> 
> 
> Thanks a lot,
> Bilge
> 

-- 
-----------------------------------------------------------
  POLAR Mühendislik ve Danışmanlık Limited Şirketi
-----------------------------------------------------------
  POLAR Engineering and Consulting Limited
-----------------------------------------------------------
  bilge@polar.biz.tr
  Adr: Teknokent, SEM Ek Binasi, ODTU, 06531 Ankara, Turkey
  Tel: + 90 - 312 - 210 14 53
  Fax: + 90 - 312 - 210 17 99
  http://www.polar.biz.tr
-----------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org