Re: Problems uploading a file in UTF-8 using Tomcat / Struts
From: Dave Glasser (dglasser_at_pobox.com)
Date: 01/13/05
- Next message: Esmond Pitt: "Re: I want an event when program I'm connected with closes Socket"
- Previous message: Esmond Pitt: "Re: Socket communication on Win32 vs Linux"
- In reply to: Robert Bowen: "Problems uploading a file in UTF-8 using Tomcat / Struts"
- Next in thread: sygsix_at_gmail.com: "Re: Problems uploading a file in UTF-8 using Tomcat / Struts"
- Reply: sygsix_at_gmail.com: "Re: Problems uploading a file in UTF-8 using Tomcat / Struts"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 12 Jan 2005 19:41:34 -0500
sygsix@gmail.com (Robert Bowen) wrote on 12 Jan 2005 09:00:17 -0800 in
comp.lang.java.programmer:
>I am using Struts' FormFile class to upload a text file from a
>multipart form.
>
>Everything works fine in Windoze but now that we have installed it in
>Linux we are getting an error reading the text file, it says it can't
>read it because it is in UTF-8.
>
>We are working in Spanish and as such have characters with accents,
>etc. Do I have to tell Tomcat (in the web.xml with the
>SetCharacterEncodingFilter filter) to treat the file as ISO-8859-1?
>
>I read that this filter is useful when you have a multipart form with
>fields of both type File and normal text fields, so that the normal
>text fields are encoded correctly, but that it doesn't affect File
>fields. And that in order to upload the file correctly I would need
>something like the Jakarta Commons upload utility class. But I imagine
>the Struts FormFile uses commons anyway, no?
I don't know anything about the Struts FormFile class, but I'm
wondering why it would would care about the encoding of the uploaded
text file. The uploaded file should be treated like a stream of binary
data, because, in reality, it could be any type of file--an image, a
Word document, a zip file, etc. Once you get the data uploaded, then
you can use your own code to figure out its encoding and do any
necessary conversions to it.
Sometimes a user's browser is set to use UTF-8 encoding, and form
parameters will be encoded that way, and that can cause problems if
you don't deal with it (especially when you have high-ASCII characters
with accents, etc.) Even if that's the case you're dealing with, I
still don't know why that should have any effect on the uploaded file
data. Like I said, the object that handles reading it from the stream
and possibly writing it to disk should be agnostic about what type of
data it actually is.
-- Check out QueryForm, a free, open source, Java/Swing-based front end for relational databases. http://qform.sourceforge.net If you're a musician, check out RPitch Relative Pitch Ear Training Software. http://rpitch.sourceforge.net
- Next message: Esmond Pitt: "Re: I want an event when program I'm connected with closes Socket"
- Previous message: Esmond Pitt: "Re: Socket communication on Win32 vs Linux"
- In reply to: Robert Bowen: "Problems uploading a file in UTF-8 using Tomcat / Struts"
- Next in thread: sygsix_at_gmail.com: "Re: Problems uploading a file in UTF-8 using Tomcat / Struts"
- Reply: sygsix_at_gmail.com: "Re: Problems uploading a file in UTF-8 using Tomcat / Struts"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|