• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Mervin Chan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would you use JavaScript when you could use the jsp to change the text. IT is more reliable that way.

Eric
 
Paul Clapham
Sheriff
Posts: 21116
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic