• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

 
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]
 
Ranch Hand
Posts: 144
Oracle Fedora Java
  • 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...!
 
Ranch Hand
Posts: 171
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic