• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Jyothi Bhogadi
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jyothi Bhogadi
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Satou,
You are right. I misread the question as a servlet being called from within a JSP
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There was an extension called "Adaptive Referer Remover", but it is not supported by Firefox's latest version.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic