This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes query strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "query strings" Watch "query strings" New topic

query strings

Justin Chu
Ranch Hand

Joined: Apr 19, 2002
Posts: 209
How to capture query strings as follows? is mapped to a servlet, and the servlet will display stuffs related to the user "chutan"
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 & .
Juanjo Bazan
Ranch Hand

Joined: Feb 04, 2002
Posts: 231
You can set different alias for your servlets in the web.xml configuration file( in the WEB-INF directory of your app).
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
use getPathInfo() and getQueryString() both methods to get what u want.
e.g. if u have,
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...
It is sorta covered in the JavaRanch Style Guide.
subject: query strings
Similar Threads
How to deploy to Root of Tomcat for Website?
keeping the directory path hidden
command to run a cron job
how to access jsps in a different pathinfo path in the same webapp using c:url
tomcat/iis - not recognizing web.xml file.