struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Gainty" <mgai...@hotmail.com>
Subject Re: multipart/form-data and character encoding
Date Tue, 30 May 2006 13:33:00 GMT
Good Morning Antonisis-

If you are sending data which is of UTF-8 characterset then you need to configure the request
e.g. request.setCharacterEncoding("UTF-8") e.g.
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequest.html#setCharacterEncoding(java.lang.String)

If you are receiving data from a UTF-8 configured server then set the response as in response.setCharacterEncoding("UTF-8")
e.g.
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletResponse.html#setCharacterEncoding(java.lang.String)

Martin -
*********************************************************************
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.



----- Original Message ----- 
From: "Antonis Lebesis" <ant.lebesis@gmail.com>
To: "Martin Gainty" <mgainty@hotmail.com>
Cc: "Struts Users Mailing List" <user@struts.apache.org>
Sent: Monday, May 29, 2006 8:14 PM
Subject: Re: multipart/form-data and character encoding


> Martin,
> 
> I' m not sure what you mean. In my Action's execute() method I get a
> request, a response and an ActionForm object. Whatever I do to the
> request or response objects, the values from the html form are already
> in the actionForm (encoded in a false way). The only way to alter the
> Strings in the actionForm is to change the method
> 
> getMyString() {
>  return this.myString;
> }
> to
> getMyString() {
>  return new String(this.myString.getBytes(), "UTF-8");
> },
> 
> which I already tried and miserably failed :)
> 
> Antonis
> 
> On 5/30/06, Martin Gainty <mgainty@hotmail.com> wrote:
>> Antonis-
>>
>> Did you set the characterEncoding for the response e.g.
>> res.setCharacterEncoding("UTF-8")
>> ???
>> Martin --
>>
>> This email message and any files transmitted with it contain confidential
>> information intended only for the person(s) to whom this email message is
>> addressed.  If you have received this email message in error, please notify
>> the sender immediately by telephone or email and destroy the original
>> message without making a copy.  Thank you.
>>
>> ----- Original Message -----
>> From: "Antonis Lebesis" <ant.lebesis@gmail.com>
>> To: "Struts Users Mailing List" <user@struts.apache.org>; "Martin Gainty"
>> <mgainty@hotmail.com>
>> Sent: Monday, May 29, 2006 7:26 PM
>> Subject: Re: multipart/form-data and character encoding
>>
>>
>> > Hello Martin,
>> >  I tried your suggestion but there is a difference in my case: The
>> > enctype in my form's declaration is "multipart/form-data" (I have to
>> > support file upload). If I leave it that way, I get the same results
>> > (no greek characters). If I change it to "multipart/form-data;
>> > charset=iso-8859-7", I get a nice exception :(
>> >
>> > javax.servlet.ServletException: BeanUtils.populate
>> > org.apache.struts.util.RequestUtils.populate(RequestUtils.java:497)
>> > org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:798)
>> > org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:205)
>> > org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
>> > org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
>> > javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
>> > javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>> >
>> > root cause
>> >
>> > java.lang.IllegalArgumentException: argument type mismatch
>> > sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>> > java.lang.reflect.Method.invoke(Method.java:585)
>> > org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1789)
>> > org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.java:1684)
>> > org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:1713)
>> > org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1019)
>> > org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
>> > org.apache.struts.util.RequestUtils.populate(RequestUtils.java:495)
>> > org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:798)
>> > org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:205)
>> > org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
>> > org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
>> > javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
>> > javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>> >
>> > Any ideas?
>> >
>> > Thanks,
>> > Antonis
>> >
>> > On 5/29/06, Martin Gainty <mgainty@hotmail.com> wrote:
>> >> Good Afternoon Antonis-
>> >>
>> >> This character encoding issue has been addressed
>> >> http://issues.apache.org/struts/browse/STR-2117 as follows
>> >>
>> >> Set your page to use correct character encoding
>> >> <%@ page ....;contentType="text/html" charset=UTF-8"%>
>> >>
>> >> Set form to use correct form encoding
>> >> <html:form action....method...enctype="application/x-www-form-urlencoded;
>> >> charset=UTF-8">
>> >>
>> >> Instruct web container to use selected charset when creating request (in
>> >> server.xml)
>> >> <Connector port..URIEncoding="UTF-8".../>
>> >>
>> >> HTH,
>> >> Martin --
>> >> ----- Original Message -----
>> >> From: "Antonis Lebesis" <ant.lebesis@gmail.com>
>> >> To: <user@struts.apache.org>
>> >> Sent: Monday, May 29, 2006 2:07 PM
>> >> Subject: multipart/form-data and character encoding
>> >>
>> >>
>> >> Hi,
>> >>  I 've searched the archives but haven't found any solution to my
>> >> latest problem. I have with a <html:file> input and a <html:text>
>> >> input. The problem is that request.getCharacterEncoding() returns null
>> >> and the text input is considered to be in iso-8859-1 encoding. In the
>> >> corresponding ActionForm's reset(), I have added the following line:
>> >>  request.setCharacterEncoding("ISO-8859-7");
>> >>
>> >> In forms that don't have a <html:file> input, the character set is
>> >> correct. The problem occurs only in this form and from what I 've
>> >> found it is caused by the fact that in the form declaration I have
>> >> added enctype="multipart/form-data".
>> >>
>> >> Has anyone solved this problem?
>> >>
>> >> Thanks,
>> >> Antonis
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> For additional commands, e-mail: user-help@struts.apache.org
>> >>
>> >>
>> >
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>
Mime
View raw message