File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Can I find out the originating link to my jsp using javascript? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Can I find out the originating link to my jsp using javascript?" Watch "Can I find out the originating link to my jsp using javascript?" New topic
Author

Can I find out the originating link to my jsp using javascript?

Mervin Chan
Greenhorn

Joined: Dec 03, 2004
Posts: 24
I have a problem.

I have a jsp page that is accessed via two different links. Depending on from which link it (the page) is accessed from, I want to display different text.

Suppose I cannot have seperate jsp pages for each link. is there a way I can identify which link it accessed from? Using javascript?
Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
Not sure if i understood you properly !!

Can't you pass some parameter in the Query String to differentiate between 2 links ?

otherwise you have to call a js function on clicking link, set a value in hidden field and submit a form inside the js function.

-Rajeev
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Why would you use JavaScript when you could use the jsp to change the text. IT is more reliable that way.

Eric
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18651
    
    8

I understood the question until you said you wanted to use Javascript to find what page requested your JSP. By the time you can use Javascript you've already generated the page and it's too late to find out. In a servlet you would use, I believe,to find the URL of the page that requested the servlet. I assume you can put that into a JSP as well.

Have you considered what you are going to do if somebody bookmarks the URL of your JSP and has the browser request it directly? You might want to consider Rajeev's suggestion.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can I find out the originating link to my jsp using javascript?