The moose likes Servlets and the fly likes request.getRequestURI() problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "request.getRequestURI() problem" Watch "request.getRequestURI() problem" New topic

request.getRequestURI() problem

chandramohan sampath

Joined: Aug 23, 2001
Posts: 2
Hi all,
I am using request.getRequestURI() to get the url of the calling page.
But, Can anyone let me know how do i get the complete url.
eg: if http://localhost:8080/servlet/abc.jsp?abc=12324&xyz=5830 is the url of the page.
when i use request.getRequestURI() I get only http://localhost:8080/servlet/abc.jsp.
But, I need to get the values of abc and yxz parameter also.
Can anyone let me know about it.
thanks a lot
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
Hi Chandru,
You can get the entire URL back by concatenating the following items :
(1) the url, accessed by request.getRequestURL()
(2) followed by a question mark character (?)
(3) and finally the query string, accessed by request.getQueryString()
If it's just the values of abc and xyz you need, these can be accessed by using the getParameter() method. For example :
Hope that helps..
Simon Brown
Co-author of Professional JSP 2nd Edition
[This message has been edited by Simon Brown (edited August 23, 2001).]
chandramohan sampath

Joined: Aug 23, 2001
Posts: 2
Hi simon,
Thanks a lot.
It's working for me.
I agree. Here's the link:
subject: request.getRequestURI() problem
It's not a secret anymore!