[opencms-dev] OT: JSP & UTF-8

Joe Desbonnet jdesbonnet at gmail.com
Thu Oct 19 19:15:27 CEST 2006


Apologies -- this is off-topic, but I thought the right people might
be here to give me some ideas:

I have a policy of working exclusively with UTF-8 for webapps. However
I have found that refactoring existing webapps to use UTF-8 is for
some reason surprisingly difficult. Take a look at the following two
JSPs: (one takes a text field in a form and the other displays the
text field)

test.jsp:
<%@page contentType="text/html; charset=UTF-8"
%><form action="test-submit.jsp" method="POST">
some text: <input type="text" name="text" size="16" />
<input type="submit" value="Send" />
</form>

test-submit.jsp:
<%@page contentType="text/html; charset=UTF-8"
%><% request.setCharacterEncoding("UTF-8"); %>
text=<%=request.getParameter("text")%>

I've got these two scripts in two separate webapps in the same
instance of Tomcat. It works correctly in one webapp and not the
other.
ie in one "á"  is displayed as "á"
and in the other "á" is mangled to "á"
(ie the UTF-8 is being intrepreted as ISO-8859-1)

Both set of scripts are identical, run on the same browser and it's in
the same tomcat, only the webapp context is different -- so I'm
guessing this must be some environment setup in web.xml

Any suggestions as to what I should try? I'm running Tomcat 5.5.16
with JDK 1.5.0_07 on Linux (in the Eclipse environment).

Any suggestions would be greatly appreciated.

Thanks,
Joe.



More information about the opencms-dev mailing list