File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes static resources Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "static resources" Watch "static resources" New topic
Author

static resources

shankar vembu
Ranch Hand

Joined: May 10, 2001
Posts: 309
Hi,
I want to track the users' requesting a static resource from my application. For example, I would like to track(log) when the user downloads an mp3 song(for example). Now for this, I wrote some code in my already existing filter. Everything works fine,when the user clicks an mp3 song(static resource, it does not goto my servlet), the code in my filter is getting executed and the user is presented a download/save page. But the problem arises when the user clicks "cancel" button instead of saving the song. When he does this, at the server I get this exception java.net.SocketException: Connection reset by peer: socket write error. I understand that when the user clicks "cancel", the response is somewhat in an incomplete state right???
Prior to this , The DefaultServlet was serving my static resources. Now when I changed my web.xml to make all the request(including static) to pass through my filter, I get this problem.
What am I missing here, how do I know if the user has requested a static resource or a servlet request? The above design was working fine but for the problem described? Any help?
Thanx
shankar.
shankar vembu
Ranch Hand

Joined: May 10, 2001
Posts: 309
i found out that this exception occurs when the client has closed the connection which exactly is happening when I click the "cancel" button instead of downloading the song. But then how did the DefaultServlet handle this situation?
Shankar.
Ken Robinson
Ranch Hand

Joined: Dec 23, 2003
Posts: 101
What App/Web server are you using?
In my opinion, the container should clean that up for you. I have run into that in some implementations, namely Sybase's EAServer. I believe they no longer log the error (they never threw an exception that I was aware of), so it's not noticable anymore.
shankar vembu
Ranch Hand

Joined: May 10, 2001
Posts: 309
Originally posted by Kenneth Robinson:
What App/Web server are you using?
In my opinion, the container should clean that up for you. I have run into that in some implementations, namely Sybase's EAServer. I believe they no longer log the error (they never threw an exception that I was aware of), so it's not noticable anymore.

I am using tomcat. Yes maybe the DefaultServlet too threw an exception and it was caught/ignored by the tomcat container. But now I have this filter in between that is causing the problem. Since I call the method filterChain.doFilter(), it must be calling the DefaultServlet and the exception is being thrown to my code. And then I have my own ways of handling exception..... So, do you think, I should hack my code to catch and ignore this exception?? I can do this, but I was thinking if there is a better design....
Well, my requirement was very simple. Just to keep track of the user downloading some mp3 songs i.e. some static resource, and I never knew this is not so simple as it might seem at the surface....
Shankar.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: static resources
 
Similar Threads
Security-Constraint
File upload component - Cancel event
resource not found display message
Deploy JSF Problem
Redirection using a Listener