tomcat-users mailing list archives

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

Hi=2C

First my configuration:  Ubuntu 9.10 Desktop=2C Tomcat 6.0.20.

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

tomcat
    webapps
        MyServlet
    DataFiles
        data1.xml
        data2.xml

On reading through various posts=2C I'm somewhat confused as to the best wa=
y (or any way=2C best=2C secure or otherwise) to access my data XML files v=
ia 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: =20

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

In this case=2C does this also allow access from any HTTP user?  Basically =
I just want the servlet to read/write to this directory and not anyone/anyt=
hing else.  I've not manage to get this going=2C 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 director=
y (as I don't want to place the DataFiles directory into the MyServlet dire=
ctory - want to keep code and data separate).

Many thanks in advance!


Cheers=2C

Bernard.
 		 	   		 =20
_________________________________________________________________
Browse profiles for FREE! Meet local singles online.
http://clk.atdmt.com/NMN/go/150855801/direct/01/=

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message