Hello all,
Perhaps someone has encountered this problem before:
I need to receive a form submit into a JSP page where the encoding
character-set is not necessarily ISO-8859-1. I built a sample form with a
JSP page with <%@ page contentType="text/html; charset=UTF-8" %>. The form
does a GET (so I can see the parameters on the URL) and seems to encode the
input correctly into UTF-8, but when I retrieve the parameters, they are
converted incorrectly. As an experiment, I had the page display
request.getCharacterEncoding() and it always reports ISO-8859-1, which would
explain the incorrect translation. I am starting to suspect that JRun's
Request object ignores the Content-Type HTTP header from the form's submit.
Anyone else experienced this and have a solution?
Rob McArthur
Here is the test page (inputtest.jsp):
<%@ page contentType="text/html; charset=UTF-8" session="false"%>
<H1>UTF-8 Input Test</H1>
<%
String input = request.getParameter("input");
if (input != null)
{
%>
Input received: <%= input %><BR />
<BR />
<% }
else
input = "";
%>
<FORM NAME="test" METHOD="GET" ACTION="inputtest.jsp" >
Type some text: <INPUT TYPE="textarea" NAME="input" VALUE="<%= input %>"><BR
/>
<INPUT TYPE="SUBMIT" NAME="submit" VALUE="Submit"><BR />
</FORM>
Request character encoding: <%= request.getCharacterEncoding() %><BR />
Request content type: <%= request.getContentType() %><BR />
Response character encoding: <%= response.getCharacterEncoding() %>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets