tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bernard Giannetti <>
Subject Accessing a directory/file outside of the webapps directory
Date Fri, 04 Jun 2010 07:54:12 GMT


First my configuration:  Ubuntu 9.10 Desktop, Tomcat 6.0.20.

I have a Java servlet (MyServlet) and from within that servlet I need to access a directory
containing data files.  The Tomcat directory structure is like this:


On reading through various posts, I'm somewhat confused as to the best way (or any way, best,
secure or otherwise) to access my data XML files via my servlet.

One method I have found is to define a context.xml file under the servlet's META-INF directory
and within specify (somehow) the path of the DataFiles directory.  Something such as:  

    <Context path="../DataFiles" docBase=""  />

In this case, does this also allow access from any HTTP user?  Basically I just want the servlet
to read/write to this directory and not anyone/anything else.  I've not manage to get this
going, so I'm not sure if Context Path is the right solution for what I'm trying to achieve.

The second method I've found is to add a grant line to catalina.policy file.  Is this the
right way to go?

Surely there is a way to access a directory outside of the webapps directory (as I don't want
to place the DataFiles directory into the MyServlet directory - want to keep code and data

Many thanks in advance!


Browse profiles for FREE! Meet local singles online.
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message