• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Request Parameters

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Usually, in a Servlet we write, for example, http://test.com/cust.do?no=1, to get details reg. say, customer no. 1. But recently I came across a URL written as http://localhost:8080/rest/customer/1.txt, which works perfectly well and the servlet returns the first record. My doubt is how the getParameter will return the value.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sunder Ganapathy:
My doubt is how the getParameter will return the value.


It won't. There are no parameters on the request.

The servlet handling this URL will have to parse the extra info on the URL to obtain the "1" value.
 
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
your webserver (Apache / IIS) can be setup to perform a URL rewrite from http://localhost:8080/rest/customer/1.txt to http://localhost:8080/rest/cust.do?no=1 (The rewritten url is not shown to the user)
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Richard Green:
your webserver (Apache / IIS) can be setup to perform a URL rewrite


Why bother? Besides, the use of Apache or other static web server to front an app server is seriously on the wane.

This can be dealt with directly in the servlet or front controller.
[ November 07, 2007: Message edited by: Bear Bibeault ]
 
Sunder Ganapathy
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks lot, Bear and Richard.
 
Sunder Ganapathy
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to do the parsing, because the servlet gives 404 error, when 1.txt is added to the URL. Really getting stumped, after having worked with regular URL handling with getParameter etc.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like you don't have the mapping set up correctly. How are you mapping the servlet?

By the way, if you want to see an example, check out FrontMan, my implementation of a Front Controller. See link in my sig.
 
Weeds: because mother nature refuses to be your personal bitch. But this tiny ad is willing:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic