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

ServletActionContext.getServletContext().getRealPath()

can any one give me an idea how i can do this?

Thanks in advance

Answers


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.


Need Your Help

How to get value and Return values from Restlet?

java web-services restlet

I am using restlet in java. I want to send data to the restlet service and perform some operation on that and then return the result to the client, receive on client side.

How to test if a Latitude/Longitude point is within a Map (not google maps)

java android

If I have a class that defines a map with the top/left defined by a longitude and latitude, and the bottom/right also defined by a longitude and latitude, how can test if a given latitude/longitude...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.