Building J2EE Web Applications with UTF-8 Support

Recently, I’ve spent some time developing a little website project and I wanted it to support multiple languages and character sets with Unicode from the beginning. This turned out to be harder than I anticipated, but is actually not a big deal now that it’s done. Mainly, the problem was documentation – the lack of it, rather. Since my application is based on J2EE, you’ll have to extrapolate for different platforms if that’s not what you are using.

The first thing you need to do is ensure that your entire stack supports UTF-8, which is a subset of Unicode that probably is good enough to handle all of your needs. For example, my application stack is Apache, Jetty, Struts, Hibernate and MySQL. I’ll save you the trouble of having to determine the level of Unicode support in all of these components by informing you that UTF-8 happily exists inside these layers.

Getting Data Out

The simple case is getting data out of the database and on to your browser’s screen. If you’re just writing your application, you’ll need to artifically populate your database with some sample text for this experiment. I found a lovely web page with all sorts of UTF-8 text in several languages, so copy/paste some of that text and get it into your database somehow. In fact, I’ll save you the trouble by providing you with some Tamil text (chosen because my closest Indian friends speak Tamil!):

நான? கண?ணாடி சாப?பிட?வேன?, அதனால? எனக?க? ஒர? கேட?ம? வராத?

Note: while Firefox and MSIE can display this Tamil text alright, Feedreader isn’t able to…

Now, if you’re using MySQL Control Center or MySQL Query Browser, you should know up front that while MySQL seems to have super UTF-8 support, neither of these tools do. Actually, Control Center seems to display UTF-8 text properly right after you paste it in, but the same text appears garbled as soon as you use SQL to get the data out. MySQL Query Browser displays the text in some incomprehensible fashion in all cases:

illegible utf-8 text

Notice, however, that it is able to properly display ISO-8859-1 text.

I had to determine that my eyes weren’t going fuzzy by using message digests to see if the data was still intact:

select md5(text_column), text_column from mytable

I stored the same text in a file on my disk and md5sum‘d that file to ensure that the digests were identical. Seems kind of a silly incompatibility for MySQL to release such a kickass database server without the proper support for UTF-8 in their admin tools.

Within Java, all java.lang.String objects are UTF-8. That’s quite cool, because it means that we can get data out of the database using Hibernate (sorry, I can’t be bothered writing SQL anymore), pass it through a Struts Action (the C in MVC) and out into a JSP (the V in MVC).

The JSP needs to be configured a little bit, though. It needs the following declaration at the beginning of the file:

< %@ page contentType="text/html; charset=utf-8" pageEncoding="UTF-8"%>

That makes sure that the right value in the Content-Type header precedes the text/html content. For the record, this header displays as follows (use LiveHTTPHeaders for your Moz/Firefox browser to watch the headers):

Content-Type: text/html; charset=utf-8

You also need this tag in the < head> of your HTML document:

< meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

This is less important in the cases where your application only provides character data in UTF-8. This convention exists because, based on a given static web page sitting on disk, a webserver cannot figure out the character encoding used therein. You can use things like mod_magic to figue out what kind of data is in the file, but it’s not smart enough to reliably determine the character set.

Getting Data In

So while getting data out of the database and through the stack is fairly straightforward, getting data from the browser turns out to be slightly more complicated. Data is usually transmitted from browsers to webservers using either the GET or POST methods in HTTP. (Yes, there’s more to HTTP than GET or POST, but when was the last time you wrote a webapp that used them?)

Typical use of a POST request will involve a webform that gets filled out by the user in their browser and then is sent to the server. How are you supposed to know what character set the user used while filling out the form? According to the HTML 4.01 specification, if you don’t specify the accept-charset attribute of the < form> tag:

The default value for this attribute is the reserved string “UNKNOWN”. User agents may interpret this value as the character encoding that was used to transmit the document containing this FORM element.

So barring a buggy browser client, you can constrain your form submission to the character set(s) specified in the accept-charset attribute. In my case, I decided to be explicit by specifying “UTF-8” as the value, rather than rely on the browser to take the default (also UTF-8, since that’s how the web page with the form was encoded).

When the user submits the form, the data is sent to our server via HTTP POST, at which point it is up to our application to process the submission. Typically, in Java-land, we build webapps on frameworks (like Struts, Spring, etc.) that sit on top of the Servlet API. The servlet API defines a number of objects that your chosen servlet container will make available to you, such as ServletRequest and ServletResponse which, predictably enough, are used to model the request and response of any HTTP request (well, the HttpServletRequest and HttpServletResponse are the HTTP-specific subclasses that we’re interested in). The ServletRequest defines many abstract methods including this:

abstract public void setCharacterEncoding(String arg) throws;

At this point, the astute reader will realise that this is exactly what we need to call on every servlet-derived method that will handle requests for our application. In Struts, subclasses of Action handle HTTP requests. The method signature of the execute() method of Action looks like this:

abstract public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception;

So the necessary work required to get Struts to process request parameters encoded with UTF-8 is exactly the same as for regular Servlet requests:


Kind of tedious, no? Well, I thought so until I found a lovely little servlet filter squirreled away in the CVS tree for Tomcat 4.0. You can configure the servlet in your web application’s web.xml descriptor with two parameters for conditionally or unconditionally setting the charater set on the current request’s request object:

< filter>
	< filter-name>Set Character Encoding< /filter-name>
	< filter-class > < /filter-class>
	< init-param >
		< param-name>encoding< /param-name>
		< param-value>UTF-8< /param-value>
	< /init-param>
	< init-param>
		< param-name>ignore< /param-name>
		< param-value>false< /param-value>
	< /init-param>
< /filter>

Now, there is one gotcha here and it has to do with the handling of GET requests. Let’s say that you expose the following URL on your site with some Japanese characters stuck as part of the URI. Go ahead and click on it.伊?屋ホームページ

Presumably, your browser URL-encoded the request as follows:…..

No big deal. This type of decoding should be handled by your servlet container. The gotcha is this, though. If you do an internal forward from the servlet that intercepts the request to another servlet with the URL-encoded text as part of the rewritten URI, you need to re-encode the URI before the forward.

In other words, if your application receives a request for this:伊?屋ホームページ

… which in turn results in a forward to this:伊?屋ホームページ

… then you will have to re-URL-encode the 伊?屋ホームページ part of the request before you do the internal forward. This seems wrong to me. I’m almost wondering if part of my application stack has some kind of bug somewhere, but I haven’t investigated that possibility. Nonetheless, this step was necessary for part of my application to function.

W3C provides some Java code here that you can take for the purpose of URL encoding and decoding strings.

Building support for UTF-8 feels good because it’s the right way to build modern applications. And since it’s much easier to start off using UTF-8 than convert later, there’s hardly any reason not to do this from the beginning.

46 thoughts on “Building J2EE Web Applications with UTF-8 Support”

  1. Thanks alot man for this article, you really saved my days 🙂


  2. Dear Sir,
    Can you send me a WAR that includes a form and support UTF-8 (Specially Persian fonts)?


  3. I’m using tomcat 5, but I still have a problem with utf-8.
    my jsp is:



    /” method=”post”>


    and my action is

    public ActionForward perform(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{

    HttpSession session = request.getSession();

    //Stringa che determina il forward
    String forward = “error”;
    String action = request.getParameter(“action”);
    System.out.println(“action = ” + action);

    String pippo = request.getParameter(“pippo”);
    String pluto = request.getParameter(“pluto”);
    String param = new String(pluto.getBytes(“UTF-8”), “UTF8”);
    System.out.println(“request.getCharacterEncoding() = ” + request.getCharacterEncoding());
    System.out.println(“pippo = ” + pippo);
    System.out.println(“pluto = ” + pluto);
    System.out.println(“param = ” + param);
    request.setAttribute(“pippo”, pippo);
    request.setAttribute(“pluto”, pluto);
    forward = “due”;
    forward = “uno”;
    } catch(Exception e){
    request.setAttribute(“message”, e.getMessage());

    return mapping.findForward(forward);


    but I can’t print utf-8 char.
    Can you help me please?

  4. Marcello,

    First put the accept-charset=UTF-8 as an attribute of your tag.

    Secondly, this is completely unnecessary: String param = new String(pluto.getBytes(?UTF-8″), “UTF8″);

    Thirdly, since you are using Struts, you ought to be pulling those variables from your ActionForm, not request parameters.

    Also, does your JSP have this?

    Let me know.

  5. a) I’ll try to put accept-charset=UTF-8 as an attribute of my tag.
    b) “String param = new String(pluto.getBytes(?UTF-8″), “UTF8″);” I know, but I have tried every think to do my code working
    c) I have the same problem with ActionForm

    Tanks Phil

  6. there is nothing to do, my application doesnt work fine in any way
    I tried to put accept-charset=UTF-8 as an attribute of my tag.

  7. Dear Phil, I resolved my problem.

    I deleted and in my jsp and I added enctype=”text/plain;charset=UTF-8″ in my form.

    I deleteted request.setCharEncoding(“utf-8”) too in my action.

    Now all works fine :->

  8. Dear Philip,

    I am trying to get my code with UTF-8 work, but so far…
    Looks like I am doing everything correct.
    I can get the UTF-8 characters from the form OK, plug them to the datatabase – also fine
    (I am sure about that because when I get the text back from the database, and log it into a text
    file, the text displays correctly). But when I try to display the same text on the jsp page, it does’t
    show up correctly.

    This is some parts of my jsp code:

    I even added “response.setCharacterEncoding(“UTF-8″);”:

    Still doesn’t work.

    However, some of the text works if before displaying it I convert string to ISO-8859-1:

    In this case MOST of the characters are displayed correctly. But… some do not.
    For example, three Danish characters (all of them capital letters) do not.
    Interesting that the same Danish characters which are NOT CAPITAL show up correctly.

    I am using JBOSS 4.01. with embedded Tomcat 5.0

    Do you have any idea what is going on and how I can solve this problem?


  9. Strange. I just posted a message, and all the jsp code which I wrote as an example disapeared from the message

  10. Does JBoss 4.01 use Hibernate 3 underneath? I had similar problems over the last weekend and I couldn’t quite figure them out either. Also, are you using md5() checksums in your database and against your String objects collected from your form to verify that the data is happily making it through all stages of the processing? Commons Codec has MD5 functionality if you are looking for some.

    Please let me know… be sure to post back here.

  11. Hi, Philip,

    Thanks for reply. JBOSS is using Oracle, no md5. In Oracle text is stored in NVARCHAR2 column.
    Text comes from the database fine – if I log it into a text file, no problem with any of the characters.
    I suspect that it might be a problem of Tomcat (my version is 5.0) – I’ve seen some postings
    where people report that the same UTF-8 code worked in some versions of Tomcat,
    and didn’t work in others. There is something that makes me think that this is might be Tomcat –
    like I said in my previous message, three Danish characters behave strangely – the capital characters
    come as garbage, and the same characters non-capital come fine.

    I thought that if this is Tomcat’s problem, may be I could write a filter that would do the job for me.
    Today I downloaded JBOSS 4.0.2 with Tomcat 5.5. I am going to install it today and test the code
    on the new version. If this is not Tomcat, then I don’t know where to look for an answer.


  12. Jboss 4.02 does indeed use Hibernate 3 underneath. Can you please try a test? Get a copy of Hibernate 2 and see if you can select/update data from your database without this corruption occurring?

  13. I am notusing JBOSS’s Hibernate (I set up the datasource to my Oracle database), but I will try
    to do this with Hibernate. So far I tried to run this code in JBOSS 4.0.2 with Tomcat 5.5.
    The same problem.

    I tried also to run this code on WebSphere 5.0 (also setting the datasource to my Oracle).
    WebSphere behaves differently. It does have the problem with the same characters, but
    it doesn’t display the words (whole words) where those characters are present . Nice solution – isnt’ it.
    I wish I could use this approach.

    From my jsp code I am trying to display the list of the cities.
    This time I display cities from the Czech Republic. When I get the list with the sities from the database,
    my jsp code is displaying each city in the browser, and logs the same city to the text file (at the same time).
    When I compare the list of the cities from the browser and from the text file, I see that the
    name of the city in the TEXT file is fine, but the same city is missing in the browser (in HTML code) –
    this is about WebSphere. JBOSS tries to display them, but incorrectly.

    I am not sure that this can be a database issue. If it is – how come that the text file displays the cities
    from the database correctly? But still, I will try Hibernate.


  14. Right, you set up your datasource to use Oracle’s database… and JBoss is connecting to your database using your Oracle driver. But how are the mappings for your entity beans set up? Those are using Hibernate 3 indirectly, right?

  15. I don’t have entity beans. I wrote a class that connects to the database directly using Oracle driver
    (in the JBOSS connection configuration file the connection is set up for UTF-8) and gets the list of
    the cities.

    Actually, the easiest way to check if it is a database issue or not is to get the jsp page read the
    list of the cities from a text file (where I have the list of the cities and from which I insert
    the cities to the database), eliminating going to the database.
    I will do that tomorrow. My guts feeling is that the result will be the same.

  16. I’ve tested the code getting the cities directly from the text (UTF-8) file.
    Yes, the result is exactly the same.

    Strange, only capital letters are affected. The same characters non-capital are fine.
    I am lost.

  17. I solved part of the problem. I can display all those characters which I read from the text file
    in the browser correctly now.

    First, I have to save file not as “UTF-8”, but as “Unicode”.
    Then, when I read text from the file, I have to do the conversion not from UTF-8, but
    from “UTF-16”:

    //out.write(new String(options.getBytes(“ISO-8859-1″),”UTF-16”));

    Then I can see all the characters correctly.

    I didn’t test it yest with the database

  18. It works nicely here with , but not for method=”GET”. Does anyone know what to change to fix this?

  19. I dont know whether its problem with GET or any JBoss Configuration problem, I could not display Taiwanese characters on JSP inspite of my
    page encoding is UTF-8, for which I have filter to set the character encoding to UTF-8.
    Can any of you guys explain clearly what need to be done to solve this problem

  20. Hi Philip,
    I having problem as followings:-
    Before the setCharacterEncoding, the output
    hreq.getParameter(“Passwd”) is able to output with value.

    Sample code:-
    System.out.println(“passwd req !!! ” + hreq.getParameter(“Passwd”));
    System.out.println(“passwd !!! ” + passwd);

    OUTPUT as below:
    passwd req !!! null
    passwd !!!

  21. Dear Philip
    Hi, seems like you are one of the fewest who discuss on this issue professionaly.
    I’m developing a web application with Struts, EJB2.0, JBoss 4.0 and MySQL5.0 and I’m dealing with persian/Farsi characters.
    The problem is that I can manually insert persian characters in my DB throgh MySQL Query Browser safe and sound and also can drag them out and display them back on my web page too. but the problem is when I need to insert some persian characters into my DB through a form (HTML Form or Struts Form).
    As a matter of fact, I think I did all you said as your article advises but it had no result at all.

    To let you have another check on my settings, it’s as following:
    1- On my input page:



    public ActionForward execute(
    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response) {

    try {
    response.setContentType(“text/html; charset=utf-8”);
    } catch (UnsupportedEncodingException e) {

    public void reset(ActionMapping mapping, HttpServletRequest request) {
    try {
    } catch (UnsupportedEncodingException e) {
    super.reset(mapping, request);

    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    try {
    } catch (UnsupportedEncodingException e) {
    return super.validate(mapping, request);

    THE ENCODING FILTER OF: SetCharacterEncodingFilter






    So, please tell me, what’s the missing part?
    is that JBoss which can not deliver me the right code?
    Please, if possible, lead me the way to a proper solution.

  22. Hi Philip,

    We have a problem in displaying the japanese characters in jsp page.
    Data from SAP gets ftp’ed to oracle server(9.x version).
    Sunone application server 7.0.0_02b is used with hibernates and struts.
    SAP has “we8dec” char set and oracle database is created with the nls lang as we8dec.
    Quest software’s Toad is used as front end tool to view database.
    We have a table customer_master which has some customer’s names in Japanese characters.
    On Toad I am able to view the japanese characters similar to SAP.
    On the jsp page I am not able to see the japanese characters correcly(shows like ?ú?{?T?[???P?~?J???i???j).
    So far I took the following steps.
    1. changed in jsp page the

    with all character sets .. utf-8 , shift-jis …

    2. Should I try the response.setCharacterEncoding(?UTF-8″);
    3. Wrote a small jsp page with select statement like this.
    r = s.executeQuery(“select convert(customer_name, ‘WE8DEC’,’WE8DEC’) from oms_sap_customer_master where customer_id in (‘57420′,’25867′,’92994′,’92995′,’92997′,’92998′,’93041′,’92750′,’92776′,’92774’)”);
    This also did not help. This convert function works on toad and displays correctly.
    Please help.

  23. Nunda, I haven’t a clue.

    You should use the technique that I outlined above where you md5 or sha1 the data at each point to see where it changes internally. You can’t rely on visual inspections with this stuff.


  24. There is a slight omission in the web.xml in that a filter-mapping section is also needed. Here is my web.xml:




  25. Phillip,

    If you have this in a war that you could send me it would be greatly appreciated. We are dealing with an application that needs to show european,
    arabic, cyrillic and asian languages (Including changing the orientation of how things are read – left to right, right to left, up to down).


    John Boyd

  26. Hi Philip. Thanks for the brilliant solution. But i have a problem unsolved. Error appears when i try to insert into
    database. i’m using Oracle 10g. When my uploaded file is in ASCii, it works fine. But when in UTF-8, it throws
    error. Any idea? Could it be, i have to configure character set in DB?

  27. Hello,

    i want to use Cyrillic characters, but when i did that receive “?????” in my database (MySQL) as record. Do someone know how to fix it?
    If someone know how, please contact me:


  28. Hello,

    I get some positive results and i want impart to you.

    First “My Configuration”
    – Database Host: SUSE Linux 10.0 32bit (support UTF-8,
    when i launch xterm i see cyrillic symbols)
    – Database Server: Mysql 5.0.21 (support UTF-8, i create all
    tables with utf-8 encoding and start server with utf support
    see next config)
    – Database Startup Option (in /etc/init.d/mysql): –default-character-set=utf8
    (this option documented and not used by default)

    – Application Server Host: SUSE Linux 10.0 32bit (support UTF-8,
    but i think it doesn`t matter what kin of host to use because we need
    only Java Virtual Mashine)
    – Application Server: JBoss 4.0.4.GA (with embed Tomcat 5.5 by default,
    support UTF-8)
    – Application Server Java Virtual Mashine: jdk1.5.0_02 (support UTF-8)

    – Developer Host: SUSE Linux 10.0 32bit (support UTF-8)
    – Development Environment: Net Beans 5.0 (support UTF-8,
    all files in project use UTF-8 encoding and compiled with utf-8 option
    to java compiller: Project Properties -> Build -> Compilling ->
    Additional compiller options: -encoding utf-8)
    – Developer Host Java Virtual Mashine: jdk1.5.0_02 (support UTF-8)

    Second “Technology”
    – Datasource tier: J2EE CMP (not Hibernate)
    – Business tier: J2EE Session Beans, J2EE Webservices Endpoints
    – Web tier: J2EE Sesion Beans, J2EE Webservices clients
    – Web tier MVC engine: Struts 1.2.7 (with Tiles, form input validation)
    – Web ties Template engine: Velocity 1.4
    – Logging System implementation: log4j (supports by JBoss)

    Third “Problem”
    If i manually insert data (from utf-8 supported client, for example
    MySQL Querry Browser) to my database table which mapped to some of
    CMP Enterprise Beans of application running on JBoss i can see in web page
    all requested data without problems. I can read all cyrillic symbols
    in Firefox browser winwdow.
    But if i try to submit data into my persistense storage via chain:
    Form Submit (method GET) -> Validation -> Struts Action -> Session Facade
    -> CMP EJB -> Database table
    i got not cyrillic symbols – i got incorrect symbols such as “??I” and others.

    Fourth “Solution”
    I try to trace all tiers of application during data submit process and
    come to a conclusion that all tiers of application work without any
    problems if i manualy put some cyrillic data in my Struts ActionForm or Action.
    So problem in JBoss web container – Embed Tomcat 5.5

    I try to search some information about Tomcat configuration and get this result:
    FAQ Topic “Apache Struts 2 Documentation > Home >
    FAQs > How to support UTF-8 URIEncoding with Tomcat”
    I implement solution as described in this topic: i edit file server.xml and
    put attribute URIEncoding=”UTF-8″ in Connector element.

    Now my J2EE Application work without prollems. I can submit and request cyrillic symbols.
    Sorry for my english (i`m from Ukrane).
    Thanks to all developers in the world.
    Regards, Vladimir Storm.

  29. Hi,
    I am trying to use cyrillic characters in my j2ee application using struts and toplink as ORM. I have tried your solutions writing
    – request.setCharacterEncoding(“UTF-8”);
    response.setContentType(“text/html; charset=utf-8″);
    in (the abstract action from which every action inherits)

    in the jsp header

    – acceptCharset=”UTF-8″ enctype=”text/plain;charset=UTF-8” in the form tag
    When writing and retrieving cyrillic characters trough TOAD there is no issue. However, the application shows these characters (фы) as, for example,&#1092&#1099, etc. If I try to edit these fields using the application, the insert or update queries have these numbers instead of the cyrillic characters. In addition, the form.get(“field”) instructions in the actions are retrieving numbers instead of the cyrillic characters entered.
    Do you have any clue about this?

  30. Hi philip
    I am using windows-1251 to support my Cyrillic data.
    I am abel to get data from my sql database bt i am getting ‘?’ everywhere
    where ever i give SOP and even on my jsp from where i am sending the string when
    the request comes back to the page . I am not using strus i have writen my own Controller class where i
    have all doget(),doPost(),doProcess() methods and from there i am calling my action servlet using the refrence
    from a .xml file.
    I have set JAVA_OPTS also to windows-1251. I have tried all this using some other encodings like iso-8859-5,
    Please reply me i am in need ur help.
    I am usinf JBoss 4.0.5, Windows 2000

  31. Hi,
    i am using MSSql 2000 and Oracle 9i database.
    Both are set to a Cyrillic collation type i am able
    to insert russian string in my tables but i want to
    know that how can i insert a cyrillic number like (10,2)
    which means 10.2 into my table column of datatype numeric??

    Please reply me

  32. Thank you so much!!!! I just spent 2 days and 30 Google searches trying to add Japanese support to my web forms before coming across your article. I just can’t believed this is documented by Tomcat and easily found.

  33. Hi Phil,

    Iam facing a problem with the special chars(Cyrillic/Russian).
    My web appl running on orion server, needs to give the input in text boxes developed in struts(JSP) form
    we can enter the chars in the boxes given will need to store in Oracle db as xml file content and get it
    translated to html(not specified any char format explicitly) I need to check these russian chars.
    When I try this chars(eg. А) in FireFox browser it is treating as html entities(&#1040) and when I give the same char in IE
    it is treating as a latin char(eg. А is a russian char) giving the int val for this char as 192, actual val given for
    this as 1040, it should treat this int val as 1040 only( Iam working on this issue since couple of weeks. I need in urgent…

    Please help me what could be done in my code.

    Thanks in advance,

  34. give the code to update a record in struts using hibernate in a page tag

  35. Hi Phil,
    I am facing a problem in my application.i m making this application with the help of struts,hibernate,jsp. this web application is for Indian language(Hindi,Marathi,Tamil,Talgu,Malayalam and so on).and to display text in these language we r using properties file.These property files r containing the text that we want to display on jsp.Good news is its working on our local server(OS-Windows XP and Server is Tomcat 5.X).but its not working after deploying it on remote server(OS-Linex and server Is TomCat-5.x).Plz Help me out…
    waiting of ur reply….

    Vishal jsshi

  36. Hi
    am passing hindi text from jsp to java action class. But in java class hindi text is printing as लिए . Plz help me out..

  37. i have a problem in getting input data as malayalam (indian) language from a jsp form to postgresql database.I am using Jboss tools version 2.0.0 G.A.

    the situation is .. i am creating a login jsp form using 2 fields name and password in unicode malayalam . when i enter input data to a form and send to database i can able to see the name and password as malayalam . But when i check it in the database they are not converted to malayalam..

    what can be the problem? i have made changes in jsp,xml and servlet in utf-8 format.

    still i got problem..

    please give me a reply

  38. i cant able to view the details in a login page as malayalam when inserting into database. but able to read from database to another form

    what is the problem?

  39. Sir

    I have same issue

    I am using struts2 , java ,mysql,hibernate 3

    and i put UTF-8 in my jsp pages

    but at the action class , the data seems like à´°à´•à´

    i used a filter

    package com.bandmis.filters;


    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.UnavailableException;

    public class SetCharacterEncodingFilter implements Filter {

    protected String encoding = “UTF-8”;

    protected FilterConfig filterConfig = null;

    protected boolean ignore = false;

    public void destroy() {
    this.encoding = null;
    this.filterConfig = null;

    public void doFilter(ServletRequest request, ServletResponse response,
    FilterChain chain)
    throws IOException, ServletException {

    if (ignore || (request.getCharacterEncoding() == null)) {
    String encoding = selectEncoding(request);
    if (encoding != null)
    if (ignore || (response.getCharacterEncoding() == null)) {
    String encoding = selectEncoding(response);
    if (encoding != null)

    chain.doFilter(request, response);

    public void init(FilterConfig filterConfig) throws ServletException {
    this.filterConfig = filterConfig;
    this.encoding = filterConfig.getInitParameter(“encoding”);
    String value = filterConfig.getInitParameter(“ignore”);
    if (value == null)
    this.ignore = true;
    else if (value.equalsIgnoreCase(“true”))
    this.ignore = true;
    else if (value.equalsIgnoreCase(“yes”))
    this.ignore = true;
    this.ignore = false;

    protected String selectEncoding(ServletRequest request) {
    return (this.encoding);
    protected String selectEncoding(ServletResponse response) {
    return (this.encoding);

    i think there is missing of character encoding ….i dont know hw to solve this issue
    hw i can solve this issue……….Please help me

Comments are closed.