This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes How do I extract a value from the URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How do I extract a value from the URL" Watch "How do I extract a value from the URL" New topic
Author

How do I extract a value from the URL

archana nitya
Greenhorn

Joined: Dec 09, 2012
Posts: 1

I have a URL www.test.com/myshort/myapp/mypage.jsp, where myshort is a column value in my database.

I will later query for the id of this shortName (in this example it is 'myshort') which I am doing as select id from mytable where shortName='myshort';

How can I extract the 'myshort' value from the entire URL? I can't do request.getParameter() since this is not a part of the url parameter. So I am trying to use request.getRequestURI().

Can you please tell me how do I parse and get shortName using request.getRequestURI()? I know there are parse and split functions in this. How exactly can I make use of it? Can someone please help me?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

Have you examined the other methods on HttpServletRequest to see if there's something you can use? (Hint: path info, cough, cough)


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
wood burning stoves
 
subject: How do I extract a value from the URL
 
Similar Threads
Extract information form URL
parse xml response in Jersey (RESTful webservice)
to set JSP HTML element values on servlet
String Extraction using regex
XPATH in Java