Solved

character encoding problem in JSP page for displaying internationalized characters

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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
thymeleaf natural templating vs JSP 2 95
servlet doXXX methods 3 49
difference of if loops 23 49
servlet example issue 6 38
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.

770 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