File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Encoding problem with File Upload Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Encoding problem with File Upload" Watch "Encoding problem with File Upload" New topic
Author

Encoding problem with File Upload

Rabee' Nawash
Greenhorn

Joined: Feb 27, 2005
Posts: 14
Dear All,
I'm using enctype="multipart/form-data" in the html:form tag, the Upload Page has many fields other than the file path field, whenever I use the Upload JSP page , the data in the other fields became rubbish(NON English Characters) , because of the enctype="multipart/form-data" in the form tag, should I make the upload thing in a pop menu so I don't use enctype in the JSP page, or there is a solution to my problem??

Thanks in advance


Best Regards,<br />Rabee' Nawash
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If you will use org.apache.struts.upload.FormFile as the type for the uploaded file in your ActionForm bean, you can have any number of other fields of other types, and Struts should populate them correctly.

For an example of this, see the upload example in the struts-examples.war file that comes with the Struts download.


Merrill
Consultant, Sima Solutions
Rabee' Nawash
Greenhorn

Joined: Feb 27, 2005
Posts: 14
I'm already using org.apache.struts.upload.FormFile but the problem is with non-english characters , the characters became rubbish
Rabee' Nawash
Greenhorn

Joined: Feb 27, 2005
Posts: 14
I found the solution to my problem, it seems its a bug reported in struts, the solution is to override the proccess method in the RequestProcessor class as following :

public void process(
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
try {
request.setCharacterEncoding("utf-8");
} catch (Exception ex) {

}
super.process(request, response);
}

the bug was reported in the following link:
http://issues.apache.org/bugzilla/long_list.cgi?buglist=29668
[ April 12, 2006: Message edited by: Rabee' Nawash ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Encoding problem with File Upload