Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Counting Number of downloads of Static file

 
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
 
Author
Posts: 531
Mac OS X Netbeans IDE Java
  • 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
 
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.
    Bookmark Topic Watch Topic
  • New Topic