my dog learned polymorphism
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "Track clicking of URL links" Watch "Track clicking of URL links" New topic

Track clicking of URL links

Mike Li

Joined: Sep 16, 2002
Posts: 5
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?
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

Joined: Mar 22, 2000
Posts: 13037
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.
(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 ]
I agree. Here's the link:
subject: Track clicking of URL links
It's not a secret anymore!