users@jersey.java.net

Re: [Jersey] encoding problems

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 28 Oct 2009 20:54:13 +0100

On Oct 28, 2009, at 8:28 PM, Felipe Gaúcho wrote:

> I am having problems trying to use a URL returned in the XML response
> with the Jersey Client:
>
>
> ------- The server response (example):
> http://fgaucho.dyndns.org:8080/arena-http/institution
>
> <ns3:pujInstitutionEntity acronym="CEFET-CE" name="Instituto Federal
> de Educação, Ciência e Tecnologia do Ceará" version="1">
> <ns3:links href="institution/CEFET-CE" rel="itself" version="0"/>
> <ns3:links href="competition?institution=CEFET-CE" rel="next"
> version="0"/>

The link contains a query parameter "institution".


> </ns3:pujInstitutionEntity>
>
>
> ------- The client code:
> Object ret = arena.path(URLDecoder.decode(link.getHref(),
> "UTF-8")).get(new
> GenericType<Collection<PujCompetitionDetailsEntity>>() {});
>
>

Try doing:

   area.uri(URI.create(link.getHref()));

https://jersey.dev.java.net/nonav/apidocs/1.1.2-ea/jersey/com/sun/jersey/api/client/WebResource.html
#uri%28java.net.URI%29

Using URLDecoder is not necessary and is also incorrect as that should
only be used for query values and parameters.

Paul.

> ------- The exception:
> GET http://localhost:8080/arena-http/competition%3Finstitution=CEJUG
> returned a response status of 404
>
>
> ------- The server code:
> links.add(new PujLinkEntity("competition?institution=" +
> institution.getAcronym(), "details"));
>
> ???
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>