character encoding problem in JSP page for displaying internationalized characters

    im using a jsp page to process form data.but form data uses multi lingual data .Form data uses UTF-8 .But i came to know that the request.getParameter() method used in JSP page's default encoding is iso-8859.How can i change the default character encoding to UTF-8. Iam using IBM Web Sphere 3.5 with servlet 2.2 specification. im not able to use request.setCharacterEncoding() method since this version does not support for that API. Is there anything that can be done on the Web Sphere to change the default encoding?
Who is Participating?

Improve company productivity with a Business Account.Sign Up

seanrowenConnect With a Mentor Commented:
setCharacterEncoding() is for overriding the character encoding used to interpret the bytes of the request, but if everything is set up correctly, you should not need to do this.

If the request from the browser says that it is sending UTF-8 data, then the container should interpret it as such with no extra effort from you. You can try using the accept-charset attribute on your page's form element ( Hopefully your users' browsers will respect this setting.

You might also consider using UTF-8 encoding on your JSP pages, and setting the page's encoding explicity using a page directive, like with:
<%@ page contentType="text/html; charset=UTF-8" %>

There is a pageEncoding attribute as well, but I think only JSP 1.2 supports this.

Even if a broken browser doesn't respect accept-charset, it may decide to use the same encoding that the page uses to send its form post. So, it might be just as well to use UTF-8 explicitly all over the place to solve this.
If all else fails, I believe you could change the default character encoding for the whole JVM by changing the file.encoding property on the command line:

java ... -Dfile.encoding=UTF-8

This is not a good solution at all though.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.