Accessing Tomcat directory path
I am working around in a problem where i need to create an upload folder in to tomcat base directory so that can place my upload files there don't want to do this inside the webapps folder.
later on i want to access this folder in my web-application to get that files being uploaded. though i got success using the below code
File dir = new File(System.getProperty("catalina.base"), "uploads");
but its giving me path like G:\Program Files\Tomcat 6.0\uploads from which i can access the files but i want the path something like this
http//localhost:// path to my upload folders
i tried various way to achieve this but nothing has worked. i was playing around this but it did't worked out
can any one give me an idea how i can do this?
Thanks in advance
Add the following to /conf/server.xml of Tomcat:
<Context docBase="G:\Program Files\Tomcat 6.0\uploads" path="/uploads" />
It'll be available by http://localhost/uploads
It should typically be the job of your apache server using a alias and virtual directory. If you want it using your application, you have to create your own servlet and get the path of the file and open the file and stream it through the servlet.