Gladwell, Ricardo X -ND wrote:
Hi All,Did you already try "getServletContext().getResourceAsStream()"?
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?
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]>
