• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I get servlet url

 
wei liu
Ranch Hand
Posts: 35
Eclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Arvind Sampath
Ranch Hand
Posts: 144
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic