aspose file tools*
The moose likes Struts and the fly likes Original request referer in Action/Interceptor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Original request referer in Action/Interceptor" Watch "Original request referer in Action/Interceptor" New topic
Author

Original request referer in Action/Interceptor

Krishna Nagadev
Ranch Hand

Joined: Jan 04, 2005
Posts: 32
How to know from where the request has come from.

request.getHeader("referer") works only when the request is made from a click of link.

is there any way or solution that I can know from which url the request has routed to my action/servlet ?

Thanks in advance.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Just look at the request?
Kabron Kline
Greenhorn

Joined: Aug 07, 2009
Posts: 20
Try calling getRequestURI() and/or getRequestURL() on the request object.
Krishna Nagadev
Ranch Hand

Joined: Jan 04, 2005
Posts: 32
Hope I am not wrong, request.getRequestURI() and request.requestURL() tells you what was requested by the user but not who requested it (ie the origin of the requester). Lets say if your webapplication is routed from Google then, I want to know that the url of Google, not requested URL ie your application url
Neeraj Vij
Ranch Hand

Joined: Nov 25, 2003
Posts: 315
it works also when a form is submitted..

thanks
neeraj.
Krishna Nagadev
Ranch Hand

Joined: Jan 04, 2005
Posts: 32
Thanks for reply, I dont see the referer in header..
Krishna Nagadev
Ranch Hand

Joined: Jan 04, 2005
Posts: 32
I think I didn't explain the problem properly.. Let me explain it again

I am implementing a Login Service for my application. Some times users may choose the page from public domain directly. So I want to capture that url initially and the request is directed to Login page. When user login is successful then I want to redirect him with the page what he requested earlier.

I can keep the originally requested url in session and I can redirect to it once the user successful in login.. This is temporary solution
Is there any other solution which dont uses session/cookie/url rewriting

Thanks,
Neeraj Vij
Ranch Hand

Joined: Nov 25, 2003
Posts: 315
referer could have been removed by the source browser/proxy/plugin..

try some other browser ? if referer is not removed explicitly, it will come in the header.

thanks
Neeraj.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Original request referer in Action/Interceptor