Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic