Reputation: 1321
I am creating an application which produces some files/directories in my WebContent folder and I would like Tomcat to serve these static files (logs of some background jobs).
However Tomcat does not seem to recognize new files (maybe files in new folders), and it keeps returning 404 for them. After Tomcat restart, the files are served Ok.
I am using Tomcat 7.0, form within the Eclipse. The files are served by the default servlet.
I assume that Tomcat somehow traverses WebContent initially and it just uses this cached list of files for faster operation. Is there a way to disable such a behavior (or maybe: what is the right way to serve new files generated by other processes)?
Thanks for help/suggestions. I am quite newbie to Tomcat, so I might be overlooking something basic.
Update (based on accepted solution)
There seems to be some duality in the webapp folder. One is in the Eclipse project (and is returned by getServletContext().getRealPath
, the other is by default somewhere in Eclipse metadata and can be seen in launch config in wtp.deploy
property. The files are somehow copied from Eclipse to the deploy dir. When I started to generate my files under wtp.deploy
, the problem got fixed.
However, I still don't know, how to solve this in proper way, which will work both under Eclipse WTP and in normal Tomcat conditions.
Update
The final solution was to avoid DefaultServlet
at all. I used FileServlet
based on http://balusc.blogspot.com/2009/02/fileservlet-supporting-resume-and.html and it works fine.
Upvotes: 1
Views: 998
Reputation: 7778
I had similar experince with Netbeans- it usually places compiled files into new folder and works with that folder. Not sure if that's the case with you; but files should be available if placed in the right folder.
Upvotes: 1