aspose file tools*
The moose likes Servlets and the fly likes How find location that invoked the servlet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How find location that invoked the servlet?" Watch "How find location that invoked the servlet?" New topic
Author

How find location that invoked the servlet?

Udara Amarasinghe
Ranch Hand

Joined: Aug 17, 2009
Posts: 109

Hi all,

Is there any resource with servlet to find the URL of the location that invoked that servlet?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

No, the servlet offers no such information. Sometimes, you can check the "Referer" header, but it is not reliable.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ninad Kulkarni
Ranch Hand

Joined: Aug 31, 2007
Posts: 802

Go through this, it may help you


SCJP 5.0 - JavaRanch FAQ - Java Beginners FAQ - SCJP FAQ - SCJP Mock Tests - Tutorial - JavaSE7 - JavaEE6 -Generics FAQ - JLS - JVM Spec - Java FAQs - Smart Questions
Jeff Ishar
Greenhorn

Joined: Jul 04, 2011
Posts: 13
ServletRequest has a method to find the URL of request. please check the API documentation.



hope it helps
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

Jeff Ishar wrote:ServletRequest has a method to find the URL of request. please check the API documentation.

That is not the same as the resource from which the servlet was invoked.
Udara Amarasinghe
Ranch Hand

Joined: Aug 17, 2009
Posts: 109

Thanks for all comments.

Seems like there is only one solution. That is client of the servlet have send his URL with the request.
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6662
    
    5

Udara Amarasinghe wrote:Thanks for all comments.

Seems like there is only one solution. That is client of the servlet have send his URL with the request.


Send the identity you mean ? Your question does not have an answer since the location that identifies a calling entity would be a IP and not a URL. A thick client can for example not be reached from a URL.

If identity is the problem, you can assign a pricinpal and role to the calling entity. That would help you authenticate and authorize the subject


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Udara Amarasinghe
Ranch Hand

Joined: Aug 17, 2009
Posts: 109

Deepak Bala wrote:Send the identity you mean ? Your question does not have an answer since the location that identifies a calling entity would be a IP and not a URL. A thick client can for example not be reached from a URL.

If identity is the problem, you can assign a pricinpal and role to the calling entity. That would help you authenticate and authorize the subject

No Deepak, I mean URL for the web page that included a link for the servlet and initiated the request for the servlet or something like that.
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6662
    
    5

In that case you should take note of Bear's comment about the Referer header. There is no standard that allows anyone to track from where a URL click originated.
 
 
subject: How find location that invoked the servlet?