• Post Reply Bookmark Topic Watch Topic
  • New Topic

getting url from where servlet called

 
Subtle Solo
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi members, herez a simple question 4 u.

i carete a html page, which is let suppose placed on
http://abc.com/abc.html

in which a link like
<a href = http://xyzwebserver.com/servlet/abcServlet > click here to run servlet .......

now, if i click on this link, servlet on server execute, it works fine
i can get information on HttpServletRequest request different info like ip address and other contents which passing thru the form of html like diffrent field, name adress etc using request.getParameter("name");

but i want to get the url from which servlet call, here in this example i want to get http://abc.com/abc.html, how i can get this

solo....
 
Scott Dunbar
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at getRequestURL() in the HttpServletRequest
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getRequestUrl() will not yeild that info; it will return the URL of the current request.

What you need to check out is the request header for "Referer".

And, "Subtle Solo",

We're pleased to have you here with us on the Ranch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
 
Komal Rattan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Referrer of the HTP Header should work.

However if you are redirecting to a different URL the referrer of the referrer would be lost. In this case, you can forward the request with the referrer URL info wrapped in the request pram list or any other methoe like a hidden field etc.
 
Subtle Solo
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can i use the referer .. can u post simple example here, bcoz i tried but its not working .. and also psot simple code for URL , i wanna check it out too,
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
YourRequestObject.getHeader("Referer")
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!