Solved

character encoding problem in JSP page for displaying internationalized characters

Posted on 2004-04-21
4
170 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
  • 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
triangle challenge 4 77
maven java path setting 5 50
Core Java. What output will be and why ? 6 58
maven project error 5 21
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

706 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now