A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Introducing JavaFX 8 Programming
this week in the
How do I extract a value from the URL
Joined: Dec 09, 2012
Dec 09, 2012 14:14:50
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?
Author and ninkuma
Joined: Jan 10, 2002
Dec 09, 2012 15:22:30
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
Books by Bear
I agree. Here's the link:
subject: How do I extract a value from the URL
parse xml response in Jersey (RESTful webservice)
to set JSP HTML element values on servlet
String Extraction using regex
XPATH in Java
Extract information form URL
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015