Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Encoding problem with File Upload

 
Rabee' Nawash
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rabee' Nawash
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm already using org.apache.struts.upload.FormFile but the problem is with non-english characters , the characters became rubbish
 
Rabee' Nawash
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic