Note that getRealPath("/WEB-INF/...") is allowed to fail (under the spec).
I know for a fact that in several containers, if your deploy as a WAR file,
it will indeed fail.Here are two alternatives that will always work to access files in /WEB-INF:
1)
String path = "/WEB-INF/myfile.ext";
InputStream istream = servletContext.getResourceAsStream(path);2)
String path = "/WEB-INF/myfile.ext";
URL url = servletContext.getResource(path);
URLConnection uconn = url.openConnection();
InputStream istream = uconn.getInputStream();What remains to solve your problem is to refactor your code to accept an InputStream rather than a File. It appears that File is used to length()
can be called on it so the byte array can be properly allocated.
If the resource is truly a file, it appears the istream.available() will
do that job for you (although I have not tested this).
Thank you...
I'll give it a try...
Cheers...
Dave
-----Original Message----- From: Jarnot Voytek Contr AU HQ/SC [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 29, 2003 12:02 PM To: 'Struts Users Mailing List' Subject: RE: Opening/reading a file from a Struts application...
-----Original Message----- From: Jarnot Voytek Contr AU HQ/SC Sent: Friday, June 27, 2003 11:53 AM To: 'Struts Users Mailing List' Subject: RE: getting a file path to /WEB-INF from a HttpSession
try
request.getSession(false).getServletContext().getRealPath("/WEB-INF/..." ))
or, in an action you could do
getServlet().getServletContext().getRealPath("/WEB-INF/...");
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Dolf Starreveld 190 Thompson Square http://www.starreveld.com Mountain View, CA 94043 Home: (650) 966-1404 Mobile: (415) 613-7229 FAX: (650) 967-2863
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

