users@jersey.java.net

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

From: Wilhelmsen Tor Iver <TorIverW_at_arrive.no>
Date: Sun, 29 Mar 2009 18:43:28 +0200

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

The testing is done using Maven's Surefire plugin on JUnit 4.4 test
classes with HttpUnit 1.6, and also manually by typing into Firefox'
address bar on a deployed instance.

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

The container when testing is ServletUnit's ServletRunner, configured to
point to the project's web.xml

The container when deployed is Glassfish 2.1 (or as Sun calls this
particular distribution Glassfish Web Space 10, i.e. "Glassfish +
modified Liferay 5.2 portal")

Before rewriting to use getQueryParameters() I had an initial version
which only searched using name; that used @QueryParam("name") which
worked fine.

> 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());
>
> ...
> }

In tests:

UriInfo.getRequestUri() = http://localhost/employees
HttpServletRequest.getQueryString() =

Under Glassfish however, it does have the complete line apparently...

So I conclude that httpunit 1.6 is broken, and that I will skip those
tests instead, and rely on the method working in well-behaved
containers... :)

(Also just tried using the latest 1.6.2 but that is even more broken,
i.e. it insists content-type is text/plain instead of
application/xml...)

Thanks for the feedback!

- Tor Iver