I am currently working on a Bilingual application (English and Arabic) with struts framework.
My application is currently built to support English characters.
Now am trying to post and read UTF-8 encoded characters on my JSP pages in Tomcat 6 environment.
So i have the basic things set up in all my jsp pages and action class.
I have set this in my action class
`request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
response.setContentType("UTF-8");`
In my jsp pages: <%@page pageEncoding="UTF-8"%>
<%@page language="java" contentType="text/html;charset=UTF-8"%>
So when i try to post Arabic characters to my jsp page, it displays junk characters.
How do i correct it? what else do i need to do to support arabic or chinese characters?
Also, am using a database to save the form once the user fills out the application. The user can either use English or arablic to fill the form.
How do i achieve this?
You need to do only two things to get UTF-8 to work for POST forms.
Put this in top of JSP:
<%@ page pageEncoding="UTF-8" %>
Put this in a Filter
which runs before your action class.
request.setCharacterEncoding("UTF-8");
Doing this inside the action class might be already too late. It should be set before you or any MVC framework gathers the request parameters.