aspose file tools*
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
JavaRanch » Java Forums » Java » Servlets
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: 1871
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: query strings