Quantcast

change server default enconding -Where to set JAVA_OPTS in catalina.sh for UTF8?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

change server default enconding -Where to set JAVA_OPTS in catalina.sh for UTF8?

Java Development Team
Hi everyone.
Iam trying to change server default enconding from ISO8859_1 to UTF8.
Till now I found 2 differrent solutions.
The fisrt one is to use the following in my catalina.sh:
set JAVA_OPTS=-Djavax.servlet.request.encoding=UTF-8 -Dfile.encoding=UTF-8

Putting this line in the start of my catalina.sh I get
Java not starting up, Tomcat not running.
Does anyone know how to fix this , if any specific .jars needed etc...

The second one is to use filters which i will try if dont get any luck with the above which seems to be more efficient solution.

Thank you
Zis


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: change server default enconding -Where to set JAVA_OPTS in catalina.sh for UTF8?

Mark Thomas-2
Java Development Team wrote:
> Hi everyone.
> Iam trying to change server default enconding from ISO8859_1 to UTF8.
> Till now I found 2 differrent solutions.
> The fisrt one is to use the following in my catalina.sh:
> set JAVA_OPTS=-Djavax.servlet.request.encoding=UTF-8
Never seen this before and Google returns zero hits.

 -Dfile.encoding=UTF-8
This is a read-only option on some platforms

> The second one is to use filters which i will try if dont get any luck with the above which seems to be more efficient solution.

Or 3, code your application for UTF-8 from the start.

Which ever way you go, you will almost certainly need to set
URIEncoding="UTF-8" on the connector.

Mark

---------------------------------------------------------------------
To start a new topic, e-mail: [hidden email]
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: change server default enconding -Where to set JAVA_OPTS in catalina.sh for UTF8?

delbd
Hi mark, not at all

1) there are 20 results for Djavax.servlet.request.encoding in google ^^
(but am really not sure this parameter really exists in tomcat)
2) URIEncoding="UTF-8" set the encoding used for html link, the default
is platform dependent.

I "suppose" the Zis wanted to set the default character encoding of the
request parameter, which is the most problematic part of http client
server, as client is suppose to tell it to server, but they most of the
time omit it. The only way i know to solve it is to write a small
servlet filter that issue a request.setEncoding("UTF-8")

btw Zis, your catalina not starting is because you need to replace your line

JAVA_OPTS=-Djavax.servlet.request.encoding=UTF-8 -Dfile.encoding=UTF-8

to the following

JAVA_OPTS="-Djavax.servlet.request.encoding=UTF-8 -Dfile.encoding=UTF-8"

(notice the little " , it's not a tomcat problem, it's a shell rule :) )

this is even better:

JAVA_OPTS="-Djavax.servlet.request.encoding=UTF-8 -Dfile.encoding=UTF-8 ${JAVA_OPTS}"


regards

Mark Thomas a écrit :

> Java Development Team wrote:
>  
>> Hi everyone.
>> Iam trying to change server default enconding from ISO8859_1 to UTF8.
>> Till now I found 2 differrent solutions.
>> The fisrt one is to use the following in my catalina.sh:
>> set JAVA_OPTS=-Djavax.servlet.request.encoding=UTF-8
>>    
> Never seen this before and Google returns zero hits.
>
>  -Dfile.encoding=UTF-8
> This is a read-only option on some platforms
>
>  
>> The second one is to use filters which i will try if dont get any luck with the above which seems to be more efficient solution.
>>    
>
> Or 3, code your application for UTF-8 from the start.
>
> Which ever way you go, you will almost certainly need to set
> URIEncoding="UTF-8" on the connector.
>
> Mark
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: [hidden email]
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>  


---------------------------------------------------------------------
To start a new topic, e-mail: [hidden email]
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: change server default enconding -Where to set JAVA_OPTS in catalina.sh for UTF8?

Mark Thomas-2
David Delbecq wrote:
> Hi mark, not at all
>
> 1) there are 20 results for Djavax.servlet.request.encoding in google ^^
> (but am really not sure this parameter really exists in tomcat)

My bad. I kept the "-" in front which, of course, suppressed the
results. The option isn't in the spec and isn't in the 5.5.x code
base. Maybe it is an option from an old version since the only
references appear to be Tomcat related.

> 2) URIEncoding="UTF-8" set the encoding used for html link, the default
> is platform dependent.

Indeed, which is why I mentioned it. As per the docs and the spec, the
default is always ISO-8859-1 regardless of the platform default
encoding. Any query parameters in the URL will be decoded on this
basis. request.setEncoding() has no effect on this unless
useBodyEncodingForURI="true" is set on the connector.

> The only way i know to solve it is to write a small
> servlet filter that issue a request.setEncoding("UTF-8")

You can make the same call within a JSP or servlet. Where makes most
sense will vary from application to application.

The other place where encoding can trip you up is if you include
static resources within a JSP. There is a fileEncoding parameter on
the default servlet that may help.

Mark

Mark

---------------------------------------------------------------------
To start a new topic, e-mail: [hidden email]
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: change server default enconding -Where to set JAVA_OPTS in catalina.sh for UTF8?

Java Development Team
I have used a sevlet filter and  translte from ISO8859_1 to UTF8 just works
through all application.

> > 1) there are 20 results for Djavax.servlet.request.encoding in google ^^
> > (but am really not sure this parameter really exists in tomcat)
>
> My bad. I kept the "-" in front which, of course, suppressed the
> results. The option isn't in the spec and isn't in the 5.5.x code
> base. Maybe it is an option from an old version since the only
> references appear to be Tomcat related.

Adding the Djavax.servlet.request.encoding gave me corect UTF8 encoding for
servlets that insert stuff directly in database which was problematic.
JAVA_OPTS="-Djavax.servlet.request.encoding=UTF-8 -Dfile.encoding=UTF-8
${JAVA_OPTS}"

The corect one thanx to david

>
> > 2) URIEncoding="UTF-8" set the encoding used for html link, the default
> > is platform dependent.
>
> Indeed, which is why I mentioned it. As per the docs and the spec, the
> default is always ISO-8859-1 regardless of the platform default
> encoding. Any query parameters in the URL will be decoded on this
> basis. request.setEncoding() has no effect on this unless
> useBodyEncodingForURI="true" is set on the connector.

I didnt knew about this parameter that is probably why URIEncoding="UTF-8"
had no effect while I was testing .

> The other place where encoding can trip you up is if you include
> static resources within a JSP. There is a fileEncoding parameter on
> the default servlet that may help.

I dont know about this either. How do I get  access to  default servlet

Thank you Mark and David
Zissis



---------------------------------------------------------------------
To start a new topic, e-mail: [hidden email]
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: change server default enconding -Where to set JAVA_OPTS in catalina.sh for UTF8?

Mark Thomas-2
Java Development Team wrote:
> I dont know about this either. How do I get  access to  default servlet

You'll only have a problem if:
- you include static resources
- the static resources are encoded other than with the default platform
encoding

If you need to make changes, the default servlet is configured in
conf/web.xml in a standard install.

Mark


---------------------------------------------------------------------
To start a new topic, e-mail: [hidden email]
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...