tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vwu98...@lycos.com
Subject Re: Encoding Issue on POST
Date Sat, 01 Jan 2011 22:21:20 GMT
Please see below.

----- Original Message -----
From: "Konstantin Kolinko" <knst.kolinko@gmail.com>
To: "Tomcat Users List" <users@tomcat.apache.org>
Sent: Saturday, January 1, 2011 11:36:29 AM GMT -08:00 US/Canada Pacific
Subject: Re: Encoding Issue on POST

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.

©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©
Do I need to ensure the encoding to be utf-8 in all situation? If so, what is the advantage
of your approach? 
©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©

>> * 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.

©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©
Does the url pattern cover all URLs?

I am wondering whether I need to dig into the Spring framework code to see where getParameter()
is called in related with the filter.
©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©

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>)?

©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©
It is a regular form, not for file uploading. 
©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©

Best regards,
Konstantin Kolinko

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



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


Mime
View raw message