Hi,
I find that too many people make bad assumptions about file system
availability. Nowhere does it say that thou must deploy from an exploded
WAR/filesystem. All too often you see resource loading code using the Evil
getRealPath API call and others instead of getResource or
getResourceAsStream.
Anyway, enough rant. To write temporary files (and there are those that
would say that a web app has no business in writing to the filesystem of the
server it's executing on - security nightmare....) you should use
File temp = (File)context.getAttribute("javax.servlet.context.tempdir");
As per the servlet spec (P30 of my version).
Enjoy,
Les
> -----Original Message-----
> From: John Burgess [mailto:[EMAIL PROTECTED]]
> Sent: 10 June 2002 11:25
> To: Tomcat Users List
> Subject: RE: How to write files when web-app is a WAR?
>
>
> If the war file is unpacked (which tomcat will do
> automatically at startup
> unless you specify somewhere in server.xml not to) then it is
> just as if you
> had deployed to the webapp\your_app directory yourself. I
> believe that
> leaving war's unpacked results in slightly worse performance and isn't
> recommended for a deployment server anyway.
>
> Best Wishes
> John Burgess
> [EMAIL PROTECTED]
> Tel: 01865 718666
> Fax: 01865 718600
>
>
> -----Original Message-----
> From: Chris Bailey [mailto:[EMAIL PROTECTED]]
> Sent: Friday, June 07, 2002 8:02 PM
> To: Tomcat Mailing List
> Subject: How to write files when web-app is a WAR?
>
>
> From what I've read, it seems that if you package your web
> application in a
> WAR file, you have no way of attaining a path on the server's
> file system
> that you can use to write files. Reference:
> http://mikal.org/interests/java/tomcat/archive/view?mesg=15006.
>
> I have a web app that we'd like to package as a WAR. But, we
> need to be
> able to write various data files out to the server's file
> system. What
> solution(s) are people using for this? Writing the files to
> a database is
> not acceptable for us (I'm not a DBMS expert, but have been
> told that BLOB
> performance is not great, and that using a DB as a file
> system replacement
> is not good, etc.).
>
> I was thinking we'd have to do a bit of a hack... Basically,
> at the time we
> "install" our application, the user will pick the real path
> on their disk
> where the data files are stored. We then store this in a property in
> web.xml, and retrieve that in the app for using as the path. For
> links/hrefs on a web page, we'd just use something like
> /data_files, but
> then set up a path-mapping that had /data_files mapped to say
> /home/appname/data_files or whatever. I also am assuming I
> will need to
> ensure that this real path lies outside of the WAR expanded directory
> because someday Tomcat (and maybe others already?) will not
> expand the WAR
> file.
>
> Anyway, what have folks come up with? While we use Tomcat for all our
> development work, we'll likely have to support a variety of Servlet
> containers (I think we can require at least Servlet 2.2,
> hopefully 2.3).
>
> ____
> Chris Bailey mailto:[EMAIL PROTECTED]
> Code Intensity http://www.codeintensity.com
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.365 / Virus Database: 202 - Release Date: 24/05/02
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.365 / Virus Database: 202 - Release Date: 24/05/02
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>