tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Les Hughes <leslie.hug...@rubus.com>
Subject RE: Can servlet write to file in /WEB-INF?
Date Mon, 24 Jun 2002 10:07:46 GMT
Hi,

getRealPath() and its ilk are really very evil. If the webapp isn't exploded
into the filesystem - i.e. it's "run" straight from the war file then you
wont be able to write to the filesystem under WEB-INF anyway. And that's not
addressing *why* a webapp requires filesystem access and the related
security issues of allowing a servlet/jsp to write into a "protected" area
like WEB-INF either.

Anyway, my 2p says you should be doing something like:-

File temp =
(File)getServletContext().getAttribute("javax.servlet.context.tempdir");  

then make a dir/file under this for your output.

Hope this helps.

Les


> -----Original Message-----
> From: andre.powroznik@belgacom.be [mailto:andre.powroznik@belgacom.be]
> Sent: 24 June 2002 09:13
> To: tomcat-user@jakarta.apache.org
> Subject: RE: Can servlet write to file in /WEB-INF?
> 
> 
> Instead there is a method in the servlet context : 
> getRealPath(String relativefilename) -> then you can open a 
> "normal" fileoutputstream.
> 
> -----Original Message-----
> From: tamir [mailto:tamir@movious.com]
> Sent: 24 June 2002 11:31
> To: 'Tomcat Users List'
> Subject: RE: Can servlet write to file in /WEB-INF?
> 
> 
> Hi,
> Making URLConnection to a directory under WEB-INF, is the 
> same like writing
> this url in the explorer.
> However, You can't go directly to any directory under WEB-INF 
> in that way,
> which justifies your failure of
> writing to this directory.
> 
> You can write to files in this directory, if you don't use 
> URLConnection.
> That's what I think
> Tamir
> 
> -----Original Message-----
> From: john-paul delaney [mailto:jp@justatest.com]
> Sent: Saturday, June 22, 2002 10:48 AM
> To: TC user list
> Subject: Can servlet write to file in /WEB-INF?
> 
> 
> 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();
> 
> 
> 
> -----------------------
>  JUSTATEST Art Online
>   www.justatest.com
> 
> 
> 
> 
> --
> 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>
> 
> **** DISCLAIMER **** 
> "This e-mail and any attachments thereto may contain information 
> which is confidential and/or protected by intellectual property 
> rights and are intended for the sole use of the recipient(s) 
> named above. 
> Any use of the information contained herein (including, but 
> not limited to, 
> total or partial reproduction, communication or distribution 
> in any form) 
> by persons other than the designated recipient(s) is prohibited. 
> If you have received this e-mail in error, please notify the 
> sender either 
> by telephone or by e-mail and delete the material from any computer. 
> Thank you for your cooperation."
> 
> 
> --
> 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
View raw message