This week's book giveaways are in the iOS and Features new in Java 8 forums.
We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes Track clicking of URL links Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Java » Servlets
Bookmark "Track clicking of URL links" Watch "Track clicking of URL links" New topic
Author

Track clicking of URL links

Mike Li
Greenhorn

Joined: Sep 16, 2002
Posts: 5
Hi,
My servlet creates a page with a list of URL links to different web sites. I like to record the date and time when user clicks on any link. Any idea how should i do this?
Thanks!
Mike.
Matthew X. Brown
Ranch Hand

Joined: Nov 08, 2000
Posts: 165
You could have the links posted back to a servlet on your site, where you record the date, time, and link hit, and then you use a RequestDispatcher to forward to the other site.
So when you reference google- your href is back to a servlet on your site that records the info, then forwards them to the new site.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12888
    
    5
Without some sort of intervention, you will never know when a user clicks a link.
In order to track the click throughs, you will have to use JavaScript to send the new location to a servlet on your system, you can count it and then do a redirect to the correct URL. The cool thing to do would be to use a code in the Javascript link so the user could not look at the source and discover the real URL.
What an interesting idea .... I could use that.
Bill
(Come to think of it Javascript is not needed - I must be doing too much Javascript these days.)
[ October 24, 2002: Message edited by: William Brogden ]
 
jQuery in Action, 2nd edition
 
subject: Track clicking of URL links