JBoss and UTF Character encoding
dargrim Jun 1, 2004 2:37 AMHi,
First, sorry for my english. It is not very good.
I build simple application who send string with Polish characters from HTML to another jsp page and display it.
I use "get" method to send this string.
and I recive what's like that "ąęśćżółń"
Bellow i put code of my simple application.
index.jsp --------------------------------------------------------------------------- <%@ page language="java" pageEncoding="UTF-8" %> <!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <title>Polish Character Encoding Test: ąćęłńóśźż</title> </head> <body> <form action="Main" method="get"> Polish string <input name="test" type="text" size="20"> <input type="submit" value="Send"> </form> </body> </html> ------------------------------------------------------------------------------- rec.jsp ------------------------------------------------------------------------------- <%@ page language="java" pageEncoding="UTF-8" %> <!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <title>Polish Character Encding Test: ĄĆĘŁŃÓŚŹŻ</title> </head> <body bgcolor="#FFFFFF"> I recive from index.jsp folowing string: "<%= request.getParameter("test") %>" </body> </html> ---------------------------------------------------------------------------------- Main.java ---------------------------------------------------------------------------------- import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class Main extends HttpServlet { protected void doGet( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { RequestDispatcher disp = request.getRequestDispatcher("rec.jsp"); disp.forward(request,response); } protected void doPost( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request,response); } }
All files are encoded in UTF-8.
If I send string vi "post" method all characters are displayed ok.
If I change "forward" method of RequestDispatcher to "include" method string is displayed ok but all polish characters on page are displayed perhaps in ISO-8859-1 encoding.
I need your help. What I do wrong?
Piotr Brandys-Buczek
My e-mail: Piotr.Buczek@telekomunikacja.pl