Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Rushi Patel
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
Parameter.png
[Thumbnail for Parameter.png]
 
Mike Zal
Ranch Hand
Posts: 144
Fedora Java Oracle
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rushi Patel
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes...!
Its working 100% ....!

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

But you are correct....!

Thanks...!
 
Anurag Verma
Ranch Hand
Posts: 167
Hibernate Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic