You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@jakarta.apache.org by "Lauriberto Alves (Engenharia-BSB)" <la...@agenciaclick.com.br> on 2005/05/20 22:09:21 UTC

What is wrong with this upload filename (UTF-8) encoding?

Hi!

 

I was trying to submit a html form which has a <html:file> tag and others <html:text> and <html:textarea> tags. I have specified “multipart/form-data” to the parameter enctype in <html:form> and I have set character-encoding in all JSP pages through the following tag: 

 

<%@ page

  language="java" 

  pageEncoding="UTF-8" 

  contentType="text/html;charset=utf-8" %>

 

I have override the method handleRequest() in a subclass of org.apache.struts.upload.CommonsMultipartRequestHandler

 

and I have put the following tag in struts-config file:

 

<controller

  contentType="text/html;charset=utf-8" 

  locale="true" 

  nocache="true"

  multipartClass="br.com.agenciaclick.struts.MyMultiPartClassHandler"/>

 

but it was not enough, because the following conflict: If the enctype of form is set to "multipart/form-data", the file submmited are well parsed and received by the server, but the text fields have not their own enctype. Thus the enctype found to each text field are "null" and the method "addTextParameter()" inside "org.apache.struts.upload.CommonsMultipartRequestHandler" class treat them as "ISO-8859-1", like this line of code:

 

value = item.getString("ISO-8859-1");

 

It would better if the information configured through <controller> tag in struts-config file was passed as parameter through the methods until here, and then the line of code above should use the character encoding specified by the programmer.

 

I have implemented this solution in my project and it has working well.

 

Thanks for this opportunity

 

Lauriberto Máximo Alves

System Analist and System Engineer

AgenciaClick Brasília - Brazil

E-mail: lauriberto.alves@agenciaclick.com.br 

Phone Number       : +55 (61)  424-5800

Work FAX Number    : +55 (61)  424-5820

Mobile Phone Number: +55 (61) 9974-3514