Hi Paul,
My clients are normal browser right now, how can i make them to declare the content-type for each part?
Thanks,
JOrdi
> Date: Mon, 2 Nov 2009 13:40:38 +0100
> From: Paul.Sandoz_at_Sun.COM
> To: users_at_jersey.dev.java.net
> Subject: Re: [Jersey] Multipart Form And Encoding
>
>
> On Nov 2, 2009, at 12:04 PM, Paul Sandoz wrote:
>
> > Hi Jordi,
> >
> > I have verified there is a bug in the FormDataBodyPart.getValue
> > method. It is ignoring the charset parameter (if present) on the
> > media type.
> >
> > In fact this method is doing it's own string parsing when it should
> > be deferring to the string reader provided of the message body reader.
> >
>
> I fixed the above.
>
> So if your client is sending multipart/form content with the
> ISO-8859-1 charset declared appropriately in the Content-Type of
> relevant body parts it should work.
>
> If you are using Jersey's FormDataMultiPart on the client side you
> will have to do something like:
>
> new FormDataMultiPart().field("name", "value",
> MediaType.valueOf("text/plain;charset=ISO-8859-1"));
>
> otherwise if you use the "field" method with two String parameters
> then UTF-8 will be used to encode the String characters. And note that
> if the charset parameter is absent when decoding then UTF-8 will be
> used to decode to String characters.
>
> Paul.
>
> > Can you:
> >
> > 1) verify there is a charset parameter present on the Content-Type
> > of the body part identified as "name"; and
> >
> > 2) try doing the following and seeing if that works (which depends
> > on a charset parameter with a value of "ISO-8859-1" being present)
> >
> > multiPart.getField("name").getValueAs(String.class);
> >
> > Paul.
> >
> >
> >
> > On Nov 2, 2009, at 11:49 AM, Jordi Domingo wrote:
> >
> >> Hi,
> >>
> >> I've got some problems with char encoding using multipart API. I've
> >> been able to solve this in my pc using:
> >>
> >> String name = multiPart.getField("name").getValue();
> >> name = new String(name.getBytes("ISO-8859-1"), "UTF-8");
> >>
> >> But in production it is not working. Chars like àáèéìí ... are
> >> shown like ??
> >>
> >> Any help is appreciated. Thanks,
> >>
> >> Jordi
> >>
> >> Entra al Nuevo Canal Motor y descubre por qué los coches más
> >> rápidos sólo aparcan en MSN. Nuevo diseño, más completo y abierto a
> >> tu opinión.¡Nuevo Canal Motor!
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> > For additional commands, e-mail: users-help_at_jersey.dev.java.net
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
_________________________________________________________________
Vive toda la experiencia de Messenger con Orange desde tu Blackberry ¡Descúbrelo!
http://serviciosmoviles.es.msn.com/messenger/blackberry.aspx
--_98e895b3-938b-4755-8dfd-d40a490f9ba0_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Hi Paul,<br><br>My clients are normal browser right now, how can i make them to declare the content-type for each part?<br><br>Thanks,<br><br>JOrdi<br><br>> Date: Mon, 2 Nov 2009 13:40:38 +0100<br>> From: Paul.Sandoz@Sun.COM<br>> To: users@jersey.dev.java.net<br>> Subject: Re: [Jersey] Multipart Form And Encoding<br>> <br>> <br>> On Nov 2, 2009, at 12:04 PM, Paul Sandoz wrote:<br>> <br>> > Hi Jordi,<br>> ><br>> > I have verified there is a bug in the FormDataBodyPart.getValue <br>> > method. It is ignoring the charset parameter (if present) on the <br>> > media type.<br>> ><br>> > In fact this method is doing it's own string parsing when it should <br>> > be deferring to the string reader provided of the message body reader.<br>> ><br>> <br>> I fixed the above.<br>> <br>> So if your client is sending multipart/form content with the <br>> ISO-8859-1 charset declared appropriately in the Content-Type of <br>> relevant body parts it should work.<br>> <br>> If you are using Jersey's FormDataMultiPart on the client side you <br>> will have to do something like:<br>> <br>> new FormDataMultiPart().field("name", "value", <br>> MediaType.valueOf("text/plain;charset=ISO-8859-1"));<br>> <br>> otherwise if you use the "field" method with two String parameters <br>> then UTF-8 will be used to encode the String characters. And note that <br>> if the charset parameter is absent when decoding then UTF-8 will be <br>> used to decode to String characters.<br>> <br>> Paul.<br>> <br>> > Can you:<br>> ><br>> > 1) verify there is a charset parameter present on the Content-Type <br>> > of the body part identified as "name"; and<br>> ><br>> > 2) try doing the following and seeing if that works (which depends <br>> > on a charset parameter with a value of "ISO-8859-1" being present)<br>> ><br>> > multiPart.getField("name").getValueAs(String.class);<br>> ><br>> > Paul.<br>> ><br>> ><br>> ><br>> > On Nov 2, 2009, at 11:49 AM, Jordi Domingo wrote:<br>> ><br>> >> Hi,<br>> >><br>> >> I've got some problems with char encoding using multipart API. I've <br>> >> been able to solve this in my pc using:<br>> >><br>> >> String name = multiPart.getField("name").getValue();<br>> >> name = new String(name.getBytes("ISO-8859-1"), "UTF-8");<br>> >><br>> >> But in production it is not working. Chars like àáèéìí ... are <br>> >> shown like ??<br>> >><br>> >> Any help is appreciated. Thanks,<br>> >><br>> >> Jordi<br>> >><br>> >> Entra al Nuevo Canal Motor y descubre por qué los coches más <br>> >> rápidos sólo aparcan en MSN. Nuevo diseño, más completo y abierto a <br>> >> tu opinión.¡Nuevo Canal Motor!<br>> ><br>> ><br>> > ---------------------------------------------------------------------<br>> > To unsubscribe, e-mail: users-unsubscribe@jersey.dev.java.net<br>> > For additional commands, e-mail: users-help@jersey.dev.java.net<br>> ><br>> <br>> <br>> ---------------------------------------------------------------------<br>> To unsubscribe, e-mail: users-unsubscribe@jersey.dev.java.net<br>> For additional commands, e-mail: users-help@jersey.dev.java.net<br>> <br> <br /><hr />En tu material escolar no puede faltar el nuevo Pack de Emoticonos Vuelta al Cole <a href='
http://www.vivelive.com/emoticonosvueltaalcole ' target='_new'>¡Descárgatelo gratis! Es muy divertido</a></body>
</html>
--_98e895b3-938b-4755-8dfd-d40a490f9ba0_--