users@jersey.java.net

Re: [Jersey] Jersey and UriInfo.getQueryParameters()

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 26 Mar 2009 17:26:23 +0100

Hi Tor,

What is the complete request URI you are using?

Paul.

On Mar 26, 2009, at 5:20 PM, Wilhelmsen Tor Iver wrote:

> Is UriInfo.getQueryParameters supposed to work? I have tried in
> 1.0.1, 1.0.2 and 1.0.3-SNAPSHOT and all three give an empty map and
> calls to getFirst() return null for the parameters I know are in the
> query.
>
> Extract from the root resource class in question:
>
> @Path("/employees")
> @Produces("application/xml")
> public class Employees {
>
> @Context
> UriInfo info;
>
> /** Detailed resource */
> @Path("{id}")
> public Object get(@PathParam("id") String id) {
> id = id.toUpperCase();
> return new Employee(id);
> }
>
> @GET
> @Produces("application/xml")
> @XmlElementWrapper(name = "employee-summaries")
> @XmlElement(name = "employee-summary")
> public List<EmployeeSummaryBean> query() {
> List<EmployeeSummaryBean> ret = null;
> if (info != null) {
> MultivaluedMap<String, String> params =
> info.getQueryParameters();
> String name = params.getFirst("name");
> String organization =
> params.getFirst("organization");
>
> At this point, both values are null. I have also tried using
> argument injection instead of attribute injection, as if that would
> make a difference.
>
> For the time being I just inject the HttpServletRequest and pick up
> the parameter values from that, but I would have loved to stick with
> the JAX-RS API :) In particular because this might later be deployed
> into an ESB that might have a custom handling of UriInfo which picks
> values from a Message instead...
>
> Is this a known bug or something? I searched the issue tracker to no
> avail...
>
> - Tor Iver
>