You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Sriram Subramanian <sr...@yahoo.com> on 2006/02/02 22:18:48 UTC

File encoding not getting set (using JVM option in service.bat)

Hi, 

I am installing Tomcat 5.5.9 as a windows service
using the service.bat script. I need to set the jvm
file encoding to UTF-8, which I did using the
following syntax -
=======
"%EXECUTABLE%" //IS//%SERVICE_NAME% --JavaHome
%JAVA_HOME% --StartPath %CATALINA_HOME% --Startup auto
--JvmOptions -Dfile.encoding=UTF-8 <more stuff>
=======
Checked the file encoding after installation...I am
seeing "Cp1252" instead of UTF-8. 
Next, I also tried setting this within catalina.bat:
=======
set JAVA_OPTS=-Dfile.encoding=UTF-8
set CATALINA_OPTS=-Dfile.encoding=UTF-8
=======
This doesn't make a difference either....I'm guessing
since service.bat does not reference catalina.bat once
the tomcat win service is installed. 
My Environment:
WinXP, Win2k3 server
Sun JRE 1.5.0_05 

I will be working on this today, will post the
solution if I find something. In the meantime, I would
really appreciate any help I can get. 

Thanks!
Sriram

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Solution: File encoding not getting set (using JVM option in service.bat)

Posted by Sriram Subramanian <sr...@yahoo.com>.
Hi Mark, and others, 

So I did find a way to set the encoding for the JVM
(and hence Tomcat 5.5 which uses this jvm and runs as
a windows service). Just add another update statement
in service.bat:
//US//SelectFederation ++JvmOptions
"-Dfile.encoding=UTF-8"

Regards,
Sriram

--- Mark Thomas <me...@virgin.net> wrote:

> Sriram Subramanian wrote:
> > Mark, I see your point related to file encoding
> > changes working on select OS/JVM combinations, why
> is
> > probably why setting LANG=en_US.UTF-8 in
> catalina.sh
> > does the trick on Unix. There's got to be some
> > workaround for Windows.
> > My aim is to force Tomcat to use UTF-8. We have a
> EAR
> > that is deployed on Tomcat, and setting the file
> > encoding to UTF-8 would help satisfy i18n
> requirements
> > for the product. Otherwise for e.g. japanese
> usernames
> > would be seen as ???.  
> 
> You can't really "force" Tomcat to use UTF-8 since a
> lot of the
> encoding is under the control of the developer.
> However what you can
> do is:
> 1) set URIEncoding="UTF-8" on the connector - this
> will help with any
> query parameters
> 2) setting fileEncoding="UTF-8" on the default
> servlet will help if
> you have any UTF-8 encoded static resources
> 3) Code the application carefully ;). This one is
> where people usually
> come unstuck. Search the archives for encoding
> filters. You should
> find some resources that may help you if you have
> problems here but be
> aware that these are sticking plasters for
> application problem rather
> than the "right" solution.
> 
> The test JSP in this post may also help you.
>
http://marc.theaimsgroup.com/?l=tomcat-user&m=108896683306201&w=2
> 
> You should be able to paste any text (Japanese,
> Chinese, English...)
> into the input text box and see the exact same text
> echoed back.
> 
> Mark
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail:
> users-help@tomcat.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: File encoding not getting set (using JVM option in service.bat)

Posted by Mark Thomas <me...@virgin.net>.
Sriram Subramanian wrote:
> Mark, I see your point related to file encoding
> changes working on select OS/JVM combinations, why is
> probably why setting LANG=en_US.UTF-8 in catalina.sh
> does the trick on Unix. There's got to be some
> workaround for Windows.
> My aim is to force Tomcat to use UTF-8. We have a EAR
> that is deployed on Tomcat, and setting the file
> encoding to UTF-8 would help satisfy i18n requirements
> for the product. Otherwise for e.g. japanese usernames
> would be seen as ???.  

You can't really "force" Tomcat to use UTF-8 since a lot of the
encoding is under the control of the developer. However what you can
do is:
1) set URIEncoding="UTF-8" on the connector - this will help with any
query parameters
2) setting fileEncoding="UTF-8" on the default servlet will help if
you have any UTF-8 encoded static resources
3) Code the application carefully ;). This one is where people usually
come unstuck. Search the archives for encoding filters. You should
find some resources that may help you if you have problems here but be
aware that these are sticking plasters for application problem rather
than the "right" solution.

The test JSP in this post may also help you.
http://marc.theaimsgroup.com/?l=tomcat-user&m=108896683306201&w=2

You should be able to paste any text (Japanese, Chinese, English...)
into the input text box and see the exact same text echoed back.

Mark


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


Re: File encoding not getting set (using JVM option in service.bat)

Posted by Sriram Subramanian <sr...@yahoo.com>.
Mark, I see your point related to file encoding
changes working on select OS/JVM combinations, why is
probably why setting LANG=en_US.UTF-8 in catalina.sh
does the trick on Unix. There's got to be some
workaround for Windows.
My aim is to force Tomcat to use UTF-8. We have a EAR
that is deployed on Tomcat, and setting the file
encoding to UTF-8 would help satisfy i18n requirements
for the product. Otherwise for e.g. japanese usernames
would be seen as ???.  

Thanks,
Sriram

--- Mark Thomas <ma...@apache.org> wrote:

> Sriram Subramanian wrote:
> > Hi, 
> > 
> > I am installing Tomcat 5.5.9 as a windows service
> > using the service.bat script. I need to set the
> jvm
> > file encoding to UTF-8, which I did using the
> > following syntax -
> > =======
> > "%EXECUTABLE%" //IS//%SERVICE_NAME% --JavaHome
> > %JAVA_HOME% --StartPath %CATALINA_HOME% --Startup
> auto
> > --JvmOptions -Dfile.encoding=UTF-8 <more stuff>
> 
> file.encoding is intended to be read only. That it
> is read/write on
> some JVM/OS combinations is a "feature" that cannot
> be relied upon to
> work in all cases.
> 
> What are you trying to do? Depending on your aims
> you might have
> better luck with some/all of the following:
> URIEncoding of the connector
> fileEncoding of the default servlet
> 
> Mark
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail:
> users-help@tomcat.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: File encoding not getting set (using JVM option in service.bat)

Posted by Mark Thomas <ma...@apache.org>.
Sriram Subramanian wrote:
> Hi, 
> 
> I am installing Tomcat 5.5.9 as a windows service
> using the service.bat script. I need to set the jvm
> file encoding to UTF-8, which I did using the
> following syntax -
> =======
> "%EXECUTABLE%" //IS//%SERVICE_NAME% --JavaHome
> %JAVA_HOME% --StartPath %CATALINA_HOME% --Startup auto
> --JvmOptions -Dfile.encoding=UTF-8 <more stuff>

file.encoding is intended to be read only. That it is read/write on
some JVM/OS combinations is a "feature" that cannot be relied upon to
work in all cases.

What are you trying to do? Depending on your aims you might have
better luck with some/all of the following:
URIEncoding of the connector
fileEncoding of the default servlet

Mark


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