File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes I am not able to get parameter value in @PathParam( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "I am not able to get parameter value in @PathParam("userID") of REST webService" Watch "I am not able to get parameter value in @PathParam("userID") of REST webService" New topic
Author

I am not able to get parameter value in @PathParam("userID") of REST webService

Rushi Patel
Greenhorn

Joined: Sep 14, 2011
Posts: 17
Respected All,
I am sending request to url as follows::

http://localhost:8084/REST_Jersey_Demo/resources/demo?userID=100

It shows me in NetBeans 7.0 HTTP SERVER MONITOR that i have got same value of userID parameter.

But when i am using it it shows me NULL value for same...!

What can be the reason ?

Can anyone help me in this ?


[Thumbnail for Parameter.png]

Mike Zal
Ranch Hand

Joined: May 04, 2011
Posts: 144

I am not a rest expert, but based a few reference materials I think I can make a few improvements

1) You need to specify the param name in @Path annotation
2) You should be using the default constructor for the class
3) You need to specify the @PathParam annotation on the methods that have the HTML annotations

Try the following changes:



The corresponding URL: http://localhost:8084/REST_Jersey_Demo/resources/demo/100

---------------------------------------------------------------------------------------------------------------------
If you are dead set of using query parameters you can try the following


In this case the original url should still work


OCJP6, OCWCD5
Rushi Patel
Greenhorn

Joined: Sep 14, 2011
Posts: 17
Yes...!
Its working 100% ....!

I got solution just after posting issue here.....!!!

But you are correct....!

Thanks...!
Anurag Verma
Ranch Hand

Joined: Mar 30, 2012
Posts: 124

One more option is like-

@Path("demo/{someContent}")
public Demo1(@PathParam("someContent") String someContent)
{
System.out.println("GOT... :: "+someContent);
}

modify variables & datatypes as per your need here.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I am not able to get parameter value in @PathParam("userID") of REST webService