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 JSP and the fly likes How can I get servlet 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 » JSP
Bookmark "How can I get servlet url" Watch "How can I get servlet url" New topic
Author

How can I get servlet url

wei liu
Ranch Hand

Joined: Nov 19, 2008
Posts: 35

Hi all,

I am trying to use request.getRequestURL().toString() to get the current page URL. instead of getting url appears in the browse (http://localhost:8080/test/abc.do) I am getting (http://localhost:8080/test/showAbc.jsp).

I am partly know why this happened, because I set to dispatcher to showAbc.jsp in the servlet class. but can anyone tell me how to get the first url that appears in the browser?

thanks in advance


SCJP 1.6 in 2010
SCWCD5 in 2011
Arvind Sampath
Ranch Hand

Joined: May 11, 2005
Posts: 144
The method getRequestURL() would return the URL of the request submitted by the client. As I understand, the method would return the URL used for submitting the request.



Did you submit the request to showAbc.jsp?

If you want to know the URL of the page from which the request was sent, you can try reading the HTTP-REFERER header. By the way, are you trying to implement some security feature using this information? If not, why do you need this info for?

Cheers
Arvind
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can I get servlet url
 
Similar Threads
tomcat4
doubt in forwarding
Can we change default method from GET to POST
Simple Servlet problem
request.getRequestURI() problem