Question about file upload with TomCat

Im creating a java website using tomcat 5.5 and eclipse. In the site i have an option to upload a file to a database, which works perfectly. The problem is that when trying to download the file from the database Tomcat does not see the file on the server.

My steps are when the page loads the file will be read from the database and saved to a physical folder on the server. The page will then populate with a link to the file on the server.

However when the file is saved on the server tomcat doesn't see the file and gives an error file not found. I have to go in ecplise and refresh the folder tree so that i can see the new files. Then the link works. How do i auto refresh tomcat to see the files?

Message was edited by:

CCFlash

Message was edited by:

CCFlash

[810 byte] By [CCFlasha] at [2007-11-27 6:30:56]
# 1

I guess the place you are saving the uploaded file in your Eclipse work directory?

Probably Eclipse is copying the files from there to another location to run Tomcat. As soon as Eclipse finds a file it deploys it to the Tomcat location.

How are you getting the upload file directory?

Take a look at the method in ServletContext: getRealPath()

It turns a website relative link into a real location on disk.

It is most useful for loading/saving files into a web application folder structure.

evnafetsa at 2007-7-12 17:55:42 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...