tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject RE: Opening Files Outside Context
Date Wed, 22 Jan 2003 14:29:59 GMT

I believe it has been discussed before that Java cannot see network drives.

Jake

At 10:07 AM 1/22/2003 +0000, you wrote:
>I know for a fact the path is correct - when I run exactly the same code
>with exactly the same file path it works... When I attempt to open the
>same file path in Tomcat I get a FileNotFoundException. The path is
>networked and on a different drive (h:) from the Tomcat and when I moved
>the target file to the same, local drive (c:) it worked. Obviously
>either Java cannot see networked drives or some sort of file filter is
>in place. Strange...
>
>--
>Ricardo Gladwell, Java Developer
>WD Internet Group, Engineering
>[t] (020) 8222 2723
>[m] (07734) 813 187
>
> > -----Original Message-----
> > From: Dan Tran [mailto:danttran@hotmail.com]
> > Sent: 21 January 2003 18:21
> > To: Tomcat Users List
> > Subject: Re: Opening Files Outside Context
> >
> >
> > I have no problem opening file outsite my context,
> >
> > Make sure you have the file path setup correctly
> >
> > -D
> > ----- Original Message -----
> > From: "Erik Price" <eprice@ptc.com>
> > To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
> > Sent: Tuesday, January 21, 2003 9:47 AM
> > Subject: Re: Opening Files Outside Context
> >
> >
> > >
> > >
> > > Gladwell, Ricardo X -ND wrote:
> > > > Hi All,
> > > >
> > > > I have written a JavaBean accessed from a JSP page in Tomcat 4.1
> > > > that opens a file to read from. However, when I open the
> > file using
> > > > the FileInputStream constructor I get a
> > FileNotFoundException. This
> > > > method works outside of Tomat on the same machine - the
> > file exists,
> > > > the path is correct even if it is on a networked drive.
> > > >
> > > > I assume this is a security feature - the file is outside the
> > > > webapps directory. What I would like to know is there anyway of
> > > > allowing Tomcat web applications to accessing files outside their
> > > > container, either through changing settings in the web.xml or
> > > > server.xml files or through the Tomcat admin tool?
> > >
> > > Did you already try "getServletContext().getResourceAsStream()"?
> > >
> > > What I have learned (yesterday) is that it is best to register an
> > > external file in the web.xml as a ContextParameter and then use
> > > getServletContext().getInitParameter() to refer to the file.  This
> > > forces whoever is deploying your app to make sure that there is in
> > > fact a resource available (and provides a means to change
> > the path of
> > > that resource without going into the code to do so).  Just some
> > > advice, I suspect you can use getResourceAsStream() without
> > consulting
> > > the ServletContext for the resource.
> > >
> > >
> > >
> > > Erik
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <mailto:tomcat-user-help@jakarta.apache.org>
> > >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:tomcat-user-> unsubscribe@jakarta.apache.org>
> > For
> > additional commands,
> > e-mail: <mailto:tomcat-user-help@jakarta.apache.org>
> >
> >
>
>--
>To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>

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