tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <knst.koli...@gmail.com>
Subject Re: Encoding Issue on POST
Date Sat, 01 Jan 2011 19:36:29 GMT
2011/1/1  <vwu98034@lycos.com>:
> * <%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%> on the first
line of JSP files
> * <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

I'd recommend
<meta http-equiv="Content-Type" content="<%=response.getContentType()%>">
to make sure that the HTTP Content-Type header and <META> tag contents
were in sync.

>> * An encoding filter for utf-8.
>
> Can you expand on that ?
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> The code can be found on the follow page:
>
> http://www.devdaily.com/java/jwarehouse/spring-framework-2.5.3/src/org/springframework/web/filter/CharacterEncodingFilter.java.shtml
>
> and the configuration in web.xml is the following:
>
> <filter>
> <filter-name>CharacterEncodingFilter</filter-name>
> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
> <init-param>
> <param-name>encoding</param-name>
> <param-value>UTF-8</param-value>
> </init-param>
> <init-param>
> <param-name>forceEncoding</param-name>
> <param-value>true</param-value>
> </init-param>
> </filter>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++

This filter should have taken care of encodings for POSTs.  Though I
am always using it with forceEncoding="false".

Maybe you forgot to map this filter? (You may throw/catch an exception
in your code and see, whether the filter is mentioned in the stack
trace.)

	<filter-mapping>
		<filter-name>CharacterEncodingFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

Things will also broke if any getParameter() call happens before the
filter. (As it will trigger parsing the body with whatever encoding is
there at that moment).
E.g., Tomcat's RequestDumperValve should not be used.

How is your <FORM> element written on the web page?  Is it a usual
POST - you are not uploading files here (i.e., you are not setting
"enctype" attribute in your <FORM>)?


Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message