tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Morris Jones <>
Subject Problem solved: character encoding for multipart forms
Date Tue, 08 Apr 2003 22:02:37 GMT
The problem:
    The tomcat examples recommend a servlet filter to do 
    request.setCharacterEncoding() so form data is properly transcoded.
    Unfortunately Tomcat doesn't process multipart forms, so they are
    left in the transfer encoding.

Multipart forms are processed in struts' upload package, and there in a
class called MultipartIterator, the form data is read and transcoded
using "ISO-8859-1" as the character encoding.

Struts provides a hook in the populate() method of RequestUtils to
get an override MultipartRequestHandler.  I made a private copy of
DiskMultiPartRequestHandler, then set the attribute for the private
copy in the constructor of my request wrapper.

Then I made a subclass of MultipartIterator.  In the constructor it
sets an encoding string from the value stored in the request.  Then the
readLine() function is overridden with a version that applies the request
character encoding to the String conversion.

Rumor has it that this problem is solved in a future version of struts.

Best regards,
Morris Jones         <*>
San Rafael, CA

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message