tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Viers <b...@po.cwru.edu>
Subject Re: Writing temporary file & downloading it?
Date Fri, 17 Oct 2003 14:45:29 GMT
The dir works for writing output to, thanks!  But I'm having problems 
linking to the file.

The directory it returns is C:\tomcat\work\Standalone\localhost\gss and 
I can write test.txt there fine.  If I try to make a hyper link to 
http://localhost:8080/gss/test.txt, though, Tomcat returns 404.  Do I 
have to do something special to tell Tomcat to serve the file?

Jason


Shapira, Yoav wrote:

>Howdy,
>A servlet container is required to supply your application with a
>directory where you can run temporary files.  This directory is
>available via 
>File tempDir = (File)
>getServletContext().getAttribute("javax.servlet.context.tempdir");
>
>You'd know the above if you'd read the servlet specification, but I'm
>getting tired of that mantra ;)
>
>Then you can say:
>File myTempFile = File.createTempFile("prefix.", ".suffix", tempDir);
>// Use a FileWriter or whatever to write your file
>
>// Stream or link this temp file's contents back to the browser
>// Stream via FileReader,
>// or directly link file File.toURI().toURL(), or whatever method you
>want
>
>You can then delete the file if you want.
>
>Yoav Shapira
>Millennium ChemInformatics
>
>
>  
>
>>-----Original Message-----
>>From: Jason Viers [mailto:bean@po.cwru.edu]
>>Sent: Thursday, October 16, 2003 9:13 PM
>>To: Tomcat Users List
>>Subject: Re: Writing temporary file & downloading it?
>>
>>Running Tomcat 4.1.27, I'm currently deploying via the "install" task
>>    
>>
>in
>  
>
>>the Ant script supplied with Tomcat, so all my files reside outside of
>>the Tomcat directory.  Otherwise, everything's pretty normal (Tomcat
>>resides in C:\tomcat).
>>
>>Just for curiosity's sake, could I find out what methods there are
>>(instead of only what someone thinks is best?).  6 months down the road
>>my situation might change (this is still in development & real
>>deployment might be different) and it'd be nice to know what my options
>>are.  Suggestions for which method is best are of course still welcome.
>>
>>Thanks
>>Jason
>>
>>Justin Ruthenbeck wrote:
>>
>>    
>>
>>>Yes, it is possible.  Give us an idea of your deployment setup (are
>>>you deploying as a .war file?  Using default root paths?  Anything
>>>special?) and we can suggest the best way to go about doing it.
>>>
>>>justin
>>>
>>>At 04:16 PM 10/16/2003, you wrote:
>>>
>>>      
>>>
>>>>Is it possible, in a servlet, to write to a temporary file in a
>>>>location that I would then be able to link to so the users can
>>>>download?  I couldn't find any information indicating either way.
>>>>
>>>>Thanks
>>>>Jason
>>>>
>>>>
>>>>
>>>>
>>>>        
>>>>
>---------------------------------------------------------------------
>  
>
>>>>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>>>        
>>>>
>>>____________________________________
>>>Justin Ruthenbeck
>>>Software Engineer, NextEngine Inc.
>>>justinr - AT - nextengine DOT com
>>>Confidential
>>>   See http://www.nextengine.com/confidentiality.php
>>>____________________________________
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>>
>>>      
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>    
>>
>
>
>
>
>This e-mail, including any attachments, is a confidential business communication, and
may contain information that is confidential, proprietary and/or privileged.  This e-mail
is intended only for the individual(s) to whom it is addressed, and may not be saved, copied,
printed, disclosed or used by anyone else.  If you are not the(an) intended recipient, please
immediately delete this e-mail from your computer system and notify the sender.  Thank you.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>  
>




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message