• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dynamic hyperlink based on predefined list

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic