Encoding Issues on Linux Server - java

Java CQ5 Application is deployed on a Linux machine. It hits a servlet(again deployed on another Linux machine) which returns an UTF-8 encoded XML in the response.
The issue is even the XML is encoded in UTF-8 , it shows � for special characters like ë.
and when i deploy the same application locally on my Windows Machine and hit the same servlet it is working fine with no encoding issues.
i have checked the default encoding of linux server it is set to en_us.utf8. i tried changing the default encoding of linux to fr_FR.utf8 but it still did not worked.
Please help !

Related

Invalid character found in the request target Tomcat 9

In the migration of a project that works correctly under Tomcat 7 to Tomcat 9 I am receiving the error Invalid character found in the request target when passing words with accents in the request.
The server.xml file was modified by introducing in the connector URIEncoding="UTF-8" and the clause relaxedQueryChars= áÁéÉíÍóÓúÚ was also introduced, but I still receive the same error. I can't touch the actual code of the project.
log traces show this: java.lang.IllegalArgumentException: Invalid character found in the request target [/sahab/lupaDem.do?filtro=LupaDem&param1=1&param2=29527&param3=OBSERVACI0xd3N%20ANTIRR0xc1BICA
HTTP does not allow to specify an encoding for the requested path. Thus in the past servers used OS settings which were actually confusing especially for applications used world-wide.
Therefore the standard established to always encode requests as UTF-8, and even then there is the URLEncoding which would prevent UTF-8 problems by %-escaping any special characters.
In a nutshell, ensure your requests are properly encoded. Previous versions of Tomcat may not have errored on this. The requests are coming from the client, not the server itself.

Euro sign is garbled on some machines

We have a web application (Java spring mvc project).
Our server returns jsons via REST API.
here is a response example from our QA env:
{currency: "EURO", symbol: "€", multiplier: 1}
here is the same response from a different enviornment (the Dev):
{currency: "EURO", symbol: "�", multiplier: 1}
Any ideas why this may happen?
OK - so my issue was with the build machine (Jenkins) which is running on ubuntu.
All the envs, that the build machine compiled and deployed our app had the issue.
I had to change the gradle tasks to be compiled with
tasks.withType(JavaCompile) { options.encoding = 'Cp1252' }
(Since we develop on windows env and thats the default).
Cheers
It's because your browser is painting out the font after all the work has been done to it in the background (on the server). This means you could have it encoded correctly at some point, but once the browser gets it, it is no longer encoded, and showing a character the browser doesn't understand.
You need to run one more pass with JavaScript on the browser side. A simple replace on the string with the proper encoding will fix it.

How do I get the Tomcat manager/status to work with my local hostname?

This works http://localhost:8080/manager/status and this doesn't http://canalistan:8080/manager/status. The Tomcat home page displays OK with either localhost or canalistan (my hostname).
I've put an entry in the hosts file. I'm using Tomcat v7, Windows 7 etc. Everything else seems to work OK and I've even managed to set up a virtual host, but this has so far eluded me.
Can you use the host name aliases for your purpose? For an example if you are using tomcat 7 try this: tomcat 7 host name aliases

Issue with microsoft word url encoding during webdav protocol

We have :
a webdav server running on Linux (java application)
a client on Windows 7, using ms-word 2010
The urls to open our files end with the files' names, and are encoded in UTF-8 before to be sent to the UI :
server.com/path/my_file_name.doc
It works perfectly with file names without special characters but with an ugly url like
server.com/path/En-tête de lettre + capital 1 050 000 €.doc
, our server does not manage to access to the file.
In the stack trace, we can see that the url received by the server is
server.com/path/En-tête de lettre + capital 1 050 000 �.doc
, but the error message that ms-word is displaying contains the right url, so I think that the original url is right.
And last but not least : it works when the server is running on a windows platform.
I suppose that ms-word re-encodes the url before transmitting it to the server, but I can't guess how to decode it.
All suggestions are welcome ^^
I'm the author of http://milton.io (java webdav server lib) and I've seen an issue where MS clients do incorrect encoding of some url's, and milton has some workarounds for that. What webdav framework/server are you using?
However, the example given looks more like mangling, as suggested by Marc B. Your server is probably outputting the propfind response in UTF-8, but windows is interpreting it as win-1252.
So you should look at the response headers and check to see what character encoding is given for the response and check that it matches the actual encoding used in the PROPFIND response.
Note that earlier versions of milton had a problem where they would use the server default encoding but always report UTF-8, so this problem would occur on any server not using UTF-8 as the default character encoding.

UTF-8 encoding problem in unix machine

Im exporting a set of data to excel in java, the data has certain non ascii characters, while exporting in Windows machine the data are coming correctly in UTF-8 encoded format.But when i deploy my code in Unix machine it is not working properly.UTF-8 encoding is not working properly.
Im using Tomcat 5.5 server.I have also included URIencoding="UTF_8" parameter in server.xml. But still in unix machine it is not working properly
Running Tomcat with a
-Dfile.encoding=UTF8
option will force the VM to adopt UTF8 as it's default encoding regardless of your environment. I suspect that's your problem (and it's good practise nonetheless)
When you are working with UTF-8 data it can be very fragile. Every step in the chain needs to specify utf8.
(1) In the database, be sure the table has UTF8 encoding and collation. "show table status" will tell you this. Google for "mysql alter table utf8" for more info.
(2) The JDBC connection needs to specify the UTF8 encoding. For Connector/J this will be something similar to:
useUnicode=true&characterEncoding=UTF-8
(3) Every stream read/write, every string to byte conversion in the code needs to specify UTF-8 as the encoding. It's easy to miss one. If it's missed Java will use the system default which will vary server to server.
(4) Not applicable here, but for user submitted data from a form, you need to set the request character encoding. (I do this in a servlet filter)
request.setCharacterEncoding("UTF-8");
(5) Probably not applicable here, but if you output HTML/XML/text from your servlet, set the HTTP character encoding header. (This might apply if you are generating the Excel file as an XML file).
response.setContentType("text/html; charset=UTF-8");

Categories

Resources