This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes Counting the number of visitors for a web page- JavaScript and Struts1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Counting the number of visitors for a web page- JavaScript and Struts1" Watch "Counting the number of visitors for a web page- JavaScript and Struts1" New topic
Author

Counting the number of visitors for a web page- JavaScript and Struts1

Dhananjaya Cn
Greenhorn

Joined: Feb 18, 2010
Posts: 2
Hi guys,

Im a new bee here.
My problem is, I need to keep track of number of vistors to a web page.
i hav planned lik this:
On load of the home page, i will call a javascript callCounter();
from javascript i need to call an action and update a record in database.

Please help me with this.
How do i call the action?
i should be in the same home jsp after updating database

I am using Struts 1 and Liferay portal.

Thanks in advance,
DJ
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I don't know why you'd do it in JavaScript; seems like if it's application-wide it would be more appropriate to put it in a custom request processor.
Dhananjaya Cn
Greenhorn

Joined: Feb 18, 2010
Posts: 2
Hi,
I am a new bee to struts. Please can you tell me how to accomplish this using RequestProcessor.

Thanks,
Dj
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

For every request get the URL (minus parameters) and increment an associated counter in the DB.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61064
    
  66

"Dhananjaya Cn", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Counting the number of visitors for a web page- JavaScript and Struts1