• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Counting Number of downloads of Static file

 
V. Aggarwal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Masoud Kalali
Author
Ranch Hand
Posts: 531
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
V. Aggarwal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
V. Aggarwal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic