Solved

character encoding problem in JSP page for displaying internationalized characters

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
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…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
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.

726 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