On Sat, 22 Jun 2002, john-paul delaney wrote:

> I was trying to see if I could write to a file in the /WEB-INF
> directory but I couldn't get it to work - is there a problem with a
> servlet writing to this directory or is it just me (again ;( ) ?
>
> thanks
> /j-p.
>
> URL url = context.getResource("/contextTest.txt");
> URLConnection con = url.openConnection();
> con.setDoOutput(true);
> OutputStream out = con.getOutputStream();
> PrintWriter pw = new PrintWriter(new OutputStreamWriter(out));
> pw.println("foo");
> pw.close();
> out.close();

Well, I've never tried it before, but what you've got is pretty much
as described in an old Jason Hunter article:

http://www.javaworld.com/jw-12-1998/jw-12-servletapi-p3.html

I don't know if things have changed since then.

Of course, another issue is whether the user that the servlet is
running as has the appropriate permissions to write into that
file/directory.

Milt Epstein
Research Programmer
Systems and Technology Services (STS)
Campus Information Technologies and Educational Services (CITES)
University of Illinois at Urbana-Champaign (UIUC)
[EMAIL PROTECTED]


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to