This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund 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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "query strings" Watch "query strings" New topic
Author

query strings

Justin Chu
Ranch Hand

Joined: Apr 19, 2002
Posts: 209
    
    1
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 & .
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).
HTH
Juanjo
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1865
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


1. Have fun @ http://faq.javaranch.com/java/JavaRaq
2. Looking for simple infix2postfix conversion and postfix evaluation package? Click here
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: query strings
 
Similar Threads
command to run a cron job
how to access jsps in a different pathinfo path in the same webapp using c:url
keeping the directory path hidden
How to deploy to Root of Tomcat for Website?
tomcat/iis - not recognizing web.xml file.