users@jersey.java.net

Re: [Jersey] Can't get request parameters due to Servlet Spec

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 31 Jul 2009 12:30:14 +0200

Hi Jon,

IMHO accessing of parameters via HttpServletRequest is broken as it
does not distinguish between query parameters (in the URI) and form
parameters (in the request entity). So i recommend not to use it.

You can process form parameters in your application using @FormParam:

   https://jersey.dev.java.net/documentation/1.1.1-ea/user-
guide.html#d4e202

or using MultivaluedMap<String, String> (or
com.sun.jersey.api.representation.Form):

   https://jersey.dev.java.net/documentation/1.1.1-ea/user-
guide.html#d4e218

If you are working in Jersey filters or with the HttpRequestContext
you can get the form parameters as follows:

   https://jersey.dev.java.net/nonav/apidocs/1.1.1-ea/jersey/com/sun/jersey/api/core/HttpRequestContext.html
#getFormParameters%28%29

Hope this helps,
Paul.

On Jul 31, 2009, at 12:16 PM, Jon Pelipas wrote:

> Hi Guys,
>
>
> I cant get the request parameters(form values) from Resource
> HttpServletRequest Object. Currently I did is create a servlet
> filter, wrap HttpServletRequest and create own copy of the raw
> request bytes. Are there better ways to do it? I need the freedom of
> accessing parameters like I usually do in Servlets.
>
> To Paul,
> Thanks for the help about singleton instance reference inquiry.
>
> Thanks,
> Jon