0

I new to servlet and trying to find a way to get the values from url for example /api/v1/http://localhost:8080/getInfo/product/1/order/22 So I know how to map url getInfo in web.xml. All I am looking for a way to get the product value and order value from url. How we do this in servlet? Any direction will be very helpful.

Thanks

user557657
  • 856
  • 1
  • 12
  • 35
  • can you give us your servlet declaration and mapping in web.xml? Also, what are you trying to do, GET, POST, PUT..? – jon Jan 20 '16 at 16:44
  • I am mapping /getInfo url in servlet. Its a get request and I want to get the value of product and order id from http://localhost:8080/getInfo/product/{product_id}/order/{order_id} – user557657 Jan 20 '16 at 17:33
  • and why not localhost:8080/getInfo?product=product_id&order=order_id – jon Jan 20 '16 at 17:44
  • I can do that but thats how api is designed. I cannot use product and order id as query string. – user557657 Jan 20 '16 at 17:46

1 Answers1

0

following the conversation, I would suggest to use request.getPathInfo() to get any information appended to the servlet url and then parse it depending on your params names.

jon
  • 910
  • 3
  • 12
  • 34