wood burning stoves*
The moose likes Tomcat and the fly likes Counting Number of downloads of Static file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Counting Number of downloads of Static file" Watch "Counting Number of downloads of Static file" New topic
Author

Counting Number of downloads of Static file

V. Aggarwal
Greenhorn

Joined: Jun 07, 2006
Posts: 4
I have a Web application running on Apache - Tomcat Server.
With the link provided on the html page (rendered to the user by the server) user can download static file from the server. I want to count the number of times that file has downloaded successfuly.

File download unsuccessful scenarios.

File Download popup will open when user tries to download file with options as 'Open', 'Save' and 'Cancel'

Scenario 1. User may press 'Cancel' button.
Scenario 2. User pressed 'Save' but while save was going on user pressed cancel button i.e. user stoped the save process in between.

Please help me out how to solve this problem


V. Aggarwal<br />SCJP, SCWCD
Masoud Kalali
Author
Ranch Hand

Joined: Jul 08, 2004
Posts: 531

as you use tomcat and you need to count the downloads that has made froman static page you can use a servlet filter.
filter will apply just on the url of your download able file.
there you can count the total number of downloads.

there should be some other ways that i am not aware , but the above will solve the problem.


here is a tutorial about filters
http://www.orionserver.com/tutorials/filters/1.html


Masoud Kalali
Software Engineer - My Weblog - GlassFish Security
V. Aggarwal
Greenhorn

Joined: Jun 07, 2006
Posts: 4
Thansk Masoud

But I guess this will not solve my problem because the criteria for the successful download is not only the clicking of URL but I have to ensure that file has been successfuly saved on the user's system.
With the filter approach I can create the response object and can have a handle to control the user response of ('Save' Or 'Cancel') but when the data will be copied from response to user system and then user presed cancel button, I will not be having any handle at that time.
Make me correct if I am wrong
Sivaraman Lakshmanan
Ranch Hand

Joined: Aug 02, 2003
Posts: 231
Hi,
Not very sure this will help you. My suggestion is just give an alert to the user after the download completes saying something like is the download was successful. If the user clicks yes then you can take that response and increase your file download count.


Regards,
Sivaraman.L
V. Aggarwal
Greenhorn

Joined: Jun 07, 2006
Posts: 4
Thanks Sivaraman,

This will realy help me if I am able to get the alert after the download is complete. I am not sure how to get the alert after the download is complete. Please explain me how to get the alert message.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Counting Number of downloads of Static file
 
Similar Threads
Keeping count of downloaded file
problem with download prompt cancel button
logging file downloads
Need Help for implementing save as dialog box for downloading a folder not a file
File download problem