• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamic hyperlink based on predefined list  RSS feed

 
Clinton Bruigom
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Javagoers

I need to develop a simple piece of html\java code which dynamically launches a different hyperlink\URL each time the link is clicked.

1st time link is accessed, launch link 1, second time launch link 2, third time launch link 3, fourth time launch link 4, fifth time launch link 1 again.... Any suggestions as to what this code may look like like? I have a an existing html web page that I need to insert the code into.

Link List
Link 1
Link 2
Link 3
Link 4

 
Greg Charles
Sheriff
Posts: 3015
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Clinton, welcome to JavaRanch!

You can't put Java into HTML, but you can make a JSP with Java scriptlets embedded or, preferably, a servlet that does the dynamic part, and a JSP that displays the results. For relatively simple behavior like this, it wouldn't take much to translate your HTML into either solution, but you would need a Java app server to be your servlet container. That is you'd need something like Tomcat, JBoss, WebLogic, etc,, to run on your server.

On the other hand, you should be able to implement what you want with JavaScript and cookies, in which case, you wouldn't need a servlet container at all.
 
Clinton Bruigom
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Greg,

Thanks for the response and the welcome!

So which would be the easiest way to do this, my site is hosted at an ISP so could ccheck whats running on their server. Once I know could you assist me in the code, im assuming it would only be a few lines, or am I way off?

Would there be any other way that I could achieve this directly in HTML?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!