RE: UTF-8 issue with JSP for tomcat server

Dear Mushtaq,

There is likely a bug in your code. I'm attaching a sample JSP you can play
with to send/retreive Arabic text (I just retested Tomcat 4.0.6 with Arabic
data and it works without problems for me).

Cheers,
Thierry

+---------------------------------------->
www.i18nGurus.com - The Open Internationalization Resources Directory.


=== Sample JSP starts here =======================
<%@ page
    language="java"
    import="java.util.Enumeration"
    pageEncoding="utf-8"
    contentType="text/html;charset=utf-8"
%>
<html>

<body bgcolor="white">

Here you test how forms behave and/or misbehave:<br>
<b>Form get</b><form method=get>
<input name='form:get'size=50 type=text>
<input type=submit value=submit>
</form>

<b>Form post</b>
<form method=post>
<input name='form:post' size=50 type=text>
<input type=submit value=submit>
</form>
<hr>
<%
	request.setCharacterEncoding("UTF-8");
	Enumeration e = request.getParameterNames();
	if(e != null && e.hasMoreElements()) {
%>
<b>Request parameters</b><br>
<br>
The parameters are read after calling request.setCharacterEncoding("UTF-8");
<bR>
<TABLE>
<TR valign=top>
	<TH align=left>Parameter:</TH>
	<TH align=left>Value:</TH>
</TR>
<%
		while(e.hasMoreElements()) {
			String k = (String) e.nextElement();
			String val = request.getParameter(k);
%>
<TR valign=top>
	<TD><%= k %></TD>
	<TD><%= val %></TD>
</TR>
<%
		}
%>
</TABLE>
<%
	}
%>
</body></html>

=== End Sample JSP =======================

Received on Monday, 16 December 2002 15:44:32 UTC