aspose file tools*
The moose likes Servlets and the fly likes Track the Jsp from where the request is coming to the Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Track the Jsp from where the request is coming to the Servlet" Watch "Track the Jsp from where the request is coming to the Servlet" New topic
Author

Track the Jsp from where the request is coming to the Servlet

Jyothi Bhogadi
Ranch Hand

Joined: Jul 08, 2005
Posts: 47
hi all,
I have a problem, where in i am trying to trace the jsp page from where the request is coming to the Particular servlet.
I have 2 different jsp pages and request from both the pages go to the same servlet at different times.... so i need to track in the servelt as to the particular request is from which jsp page.....

Can anybody please help me on this....

thanks and Regards
Jyothi.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

In every JSP files, you could put some information in the request to tell the servlet which JSP sent it. A request parameter for example.


[My Blog]
All roads lead to JavaRanch
Jyothi Bhogadi
Ranch Hand

Joined: Jul 08, 2005
Posts: 47
hi Satou,
thnks for the reply.
I guess that does help.... but just curious to know if there is any standard way using the API.....to get the name of the jsp....

Thanks and Regards
Jyothi.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

I don't think there is such standard way to do this (like API methods)
I've also heard of using HTTP header called "Referer", but it is not reliable.

(please be careful of this forum's policy about your login name)
Virag Saksena
Ranch Hand

Joined: Nov 27, 2005
Posts: 71
Actually it is available.
Look at the interface HttpServletRequest
Method getRequestURI should give you the JSP page requested by the user, though you might have to parse it from the actual servername


<a href="http://www.auptyma.com" target="_blank" rel="nofollow">The Peak of Performance</a>
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

getRequestURI() won't tell FROM which JSP the request is coming, but TO which location it is going (the servlet itself in this case)
Jyothi Bhogadi
Ranch Hand

Joined: Jul 08, 2005
Posts: 47
hi virag,
i think satou is right.....
getRequestURI()does not give the jsp page from where the request is coming....

Regards
Jyothi.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

There is nothing in the API that will tell you what JSP generated the request.
Requests don't have to be from JSPs. They could be from static HTML pages, custom, clients, other servlets, etc...

If you need to know this then the advice from Satou is your best bet.
Just add a parameter to the query string or HTML form with an identifier.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60991
    
  65

"B.Jyothi"

Please adjust your display name to have a space netween the B. and the Jyothi in order to comply with the JavaRanch naming policy.

thanks
bear
Forum bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026

Posted by Satou kurinosuke
I've also heard of using HTTP header called "Referer", but it is not reliable.


I thought Referer is the best choice here. Can u tell me why it isn't reliable.


Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Web browsers tend to set the Referer header the way they want.
http://www.webtechniques.com/archives/1998/09/webm/

This would be a good technique if it was always set properly, which is not the case.
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
Thanks for your quick response Satou kurinosuke. I will go through it after lunch and get back to you if there is any issue.
Virag Saksena
Ranch Hand

Joined: Nov 27, 2005
Posts: 71
Satou,
You are right. I misread the question as a servlet being called from within a JSP
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
If I want to include a link to a particular page of a website from my site but I don't want them to know about my site file path. Is there a way to suppress the referer fields. Is there any option in browsers(FireFox esp)
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

There was an extension called "Adaptive Referer Remover", but it is not supported by Firefox's latest version.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Track the Jsp from where the request is coming to the Servlet