users@jersey.java.net

Re: Re: [Jersey] QueryParam not injected

From: Anna Vagelin <anna.vagelin_at_tactel.se>
Date: Thu, 04 Jun 2009 17:35:05 +0200

Hi Paul,

Thank you for taking the time! Your right, the RequestWrapper we used
did not wrap the HttpServletRequest.getQueryString() and the request URI
was missing the resolution parameter.

Thanks again!

/Anna


Paul Sandoz skrev:
> <div class="moz-text-flowed" style="font-family: -moz-fixed">
> On Jun 3, 2009, at 3:45 AM, Anna Vagelin wrote:
>
>> Hi,
>>
>> I'm trying Jersey in a Apache Tomcat solution where we used to run
>> all requests through Servlets. There is a filterchain with filters
>> doing all sorts of things e.g. adding parameters to the incoming
>> request.
>
> How are the filters adding parameters?
>
> Jersey extracts the query parameters from the request URI. Namely,
> from the HttpServletRequest.getQueryString().
>
> You can print out the request URI Jersey is using, that was created
> from the servlet by using UriInfo, for example
>
> @Context UriInfo ui;
>
> ...
>
> System.out.println(ui.getRequestUri());
>
> I would be interested in knowing what the request URI is. I suspect
> that it does not have the "resolution" query parameter.
>
> Paul.
>
>> When injecting one of these additional parameters as @QueryParam into
>> the Resource, the parameter is null. However, if injecting the
>> request via @Context and then pulling the parameter from it the
>> parameter is instantiated correctly. How is this possible? What can I
>> do to be able to use the @QueryParam?
>>
>> I'm using Jersey 1.0.
>>
>> @GET
>> @Produces("*/xml")
>> public Response getXml(@QueryParam("resolution") @DefaultValue("not
>> defined") String resolution, @Context HttpServletRequest request)
>> throws IOException {
>>
>> if (resolution == "not defined") {
>> System.out.println("Resolution not defined in parameter);
>> //Always printed
>> }
>> if (request != null) {
>> System.out.println("Resolution from request" +
>> request.getParameter("resolution")); //Always printed correctly
>> }
>>
>> return ...
>> }
>>
>> Best Regards
>>
>> Anna Vagelin
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
> </div>
>