users@jersey.java.net

Jersey empties request.getParameterMap with POST

From: Ramakrishnan Meenakshi Sundaram <ramki982_at_gmail.com>
Date: Tue, 5 Jan 2010 07:54:40 +0530

Hi all,

I've evaluating Jersey for quite a while now. I find that when we have a
@POST method - to access the form parameters, it is required to use either
@FormParam or a MultiValuedMap.

In case, there is legacy library code that accepts a HttpServletRequest and
tries to read the form data using request.getParameter("<some form field
name>"), it seems to return null.

Sample Code:
@Path("/testpost")
public class TestPost{
       @POST
       public String processPost(@FormParam("username") String username,
@Context HttpServletRequest request){

               System.out.println("Username from formparam:" +
username);//returns proper data
               //whereas to mimick the legacy code, following is the test
code
               System.out.println("Username from request object:"
+ request.getParameter("username")); //reurns null
       }
}

I'm using Tomcat 5.5 and Jdk1.5. Any help on this would be definitely
helpful

with best regards
Ramakrishnan


-- 
With the divine blessings of Kamakala Kameshwari
View my blog http://shalomallone.blogspot.com