2

I work in Java on a web application servlet / jsp and I have a problem today:
After validating a form, I pass the value of an input field as a parameter (GET). I was careful to use the method javax.net.URLEncoder.encode (String, "UTF-8") but when this setting is composed of accents, the encoding of the value obtained in the second servlet is incorrect.
However I use the method URLDecoder.decode ((String) request.getParameter ("id"), "UTF-8")

Ex: 
id = éssai ==> http://127.0.0.1:8080/LdapJavaNet/groupe?action=consulter&id=%C3%A9ssai

print (URLDecoder.decode ((String) request.getParameter ("id"), "UTF-8")) ==> éssai  

Anyone can help me to fix this charset problem?

1 Answer 1

4

getParameter() returns decoded value, so you don't need to call decode().

Configurtation of encoding used by getParameter() depends on your servlet container. For example, in Tomcat it can be configured using URIEncoding attribute.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, where can i configure this attribute? can i do this in my servlet? (because my application will be running on a distant server)
Hi, Thanks for your tip but that does not resolve my encoding problem, i've tried to type manually the accent in the adress bar and miracle that work!! so i've solved my problem just removing the URLEncoder.encode() method :) Hope this can help someone, bye!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.