Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

query strings

 
Ranch Hand
Posts: 209
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to capture query strings as follows?
http://www.mysite.com/MyApp/SomeServlet/chutan
http://www.mysite.com/MyApp/SomeServlet is mapped to a servlet, and the servlet will display stuffs related to the user "chutan"
and
http://www.mysite.com/MyApp/SomeServlet/chutan?view=1
How to allow the servlet to get those parameters?

The reason I'd like to do this is that users will be able to remember the url to their personalized page easier without the ? and & .
 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can set different alias for your servlets in the web.xml configuration file( in the WEB-INF directory of your app).
HTH
Juanjo
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
use getPathInfo() and getQueryString() both methods to get what u want.
e.g. if u have,
http://myserver.com/servlet/myservlet/myname?view=1&choice=2
then u can do,
request.getPathInfo that returns "/myname" and
request.getQueryString returns view=1&choice=2
read Servlet API for more info about these methods...
or u can use request.getParameter as well to get view or choice parameters directly...
hth
maulin
 
Won't you please? Please won't you be my neighbor? - Fred Rogers. Tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic