I have no problem opening file outsite my context, Make sure you have the file path setup correctly
-D ----- Original Message ----- From: "Erik Price" <[EMAIL PROTECTED]> To: "Tomcat Users List" <[EMAIL PROTECTED]> 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:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>