Solved

character encoding problem in JSP page for displaying internationalized characters

Posted on 2004-04-21
4
175 Views
Last Modified: 2010-03-31
hi
    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?
0
Comment
Question by:manojgvr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
seanrowen earned 310 total points
ID: 10882683
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 (http://www.w3.org/TR/REC-html40/interact/forms.html). 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.
0
 
LVL 1

Expert Comment

by:seanrowen
ID: 10882766
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.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question