users@jersey.java.net

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

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 27 Mar 2009 13:30:34 +0100

On Mar 27, 2009, at 12:33 PM, Wilhelmsen Tor Iver wrote:

> > What is the complete request URI you are using?
>
> e.g. http://server:port/EmployeeInfoService/employees?name=Tor
>
> Since it runs the method it has found the right resource class, but
> it has not picked up the request parameters from the GET URL.
>

That is odd. We have many unit tests that would fail if the behavior
you describe occurred in our testing environment.

How are you sending the request, using a browser? or say using curl?

What Web container are you using? do you have any "filters" configured
for that container that modify the request URI?

I wonder if you could modify your "query" method as follows to print
out some stuff:


       public ... query(@Context HttpServletRequest hsr) {
          System.out.println("UriInfo.getRequestUri() = " +
info.getRequestUri());

          System.out.println("HttpServletRequest.getQueryString() = "
+ hsr.getQueryString());

          ...
       }


Jersey obtains the query parameters from the
HttpServletRequest.getQueryString() value. It constructs the request
URI as follows:

         String queryParameters = request.getQueryString();
         if (queryParameters == null) {
             queryParameters = "";
         }

         final URI requestUri =
absoluteUriBuilder.replacePath(request.getRequestURI()).
                 replaceQuery(queryParameters).
                 build();

Paul