tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Bailey" <ch...@codeintensity.com>
Subject RE: Can servlet write to file in /WEB-INF?
Date Mon, 24 Jun 2002 13:12:59 GMT
Right, keep in mind the whole WAR file aspect.  If your web app is not
packaged as a WAR file then it's less of an issue, and you could use
getRealPath, but if it is a WAR - even if it gets expanded by the container,
you can't use getRealPath and should write to a temp directory, or some
other directory you set up (you could store the location of this other
directory as a property in your web.xml file, etc.).

-----Original Message-----
From: Les Hughes [mailto:leslie.hughes@rubus.com]
Sent: Monday, June 24, 2002 3:08 AM
To: 'Tomcat Users List'
Subject: RE: Can servlet write to file in /WEB-INF?


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>



--
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