Velocity servlet : allow to configure request encoding
In Tomcat, Velocity servlet decodes an HTML Form's POST parameters using Tomcat's default encoding ISO-8859-1 (because browsers don't provide encoding), which produces ugly (c)-like badly encoded characters on server side when commonly expecting UTF-8.
This is a well known case, see :
- tomcat's own and most common solution, using a ServletFilter doing request.setCharacterEncoding() http://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q2 http://tomcat.apache.org/tomcat-7.0-doc/config/filter.html#Set_Character_Encoding_Filter
- and source http://code.google.com/p/forsecond/source/browse/trunk/compare/src/com/jz/filter/SetCharacterEncodingFilter.java?r=39
- discussion http://stackoverflow.com/questions/8391675/utf-8-encoding-a-servlet-form-submission-with-tomcat
Note that Velocity's own servlet does not handle it (but allows to configure output content type) http://www.docjar.org/html/api/org/apache/velocity/tools/view/servlet/VelocityViewServlet.java.html