webtier@glassfish.java.net

Re: Where to generate and store temporary files?

From: John Yeary <johnyeary_at_gmail.com>
Date: Sat, 21 May 2011 08:29:46 -0400

I do the same thing. I generate PDF files, and use the attribute Ryan
references. It works perfectly fine.

On Fri, May 20, 2011 at 1:46 PM, Ryan Lubke <ryan.lubke_at_oracle.com> wrote:

> On 5/20/11 10:18 AM, forums_at_java.net wrote:
>
> Hi
>
> My managed bean will generate PDF based on the user inputs. These PDFs are
> temporary, it is only valid for one specific request. I'm wondering where
> is
> the correct directory I should generate these PDFs ...
>
> Currently, I'm generating these PDFs to
> C:\glassfish3\glassfish\domains\domain1\applications\myapp like this:
>
> ExternalContext context =
> FacesContext.getCurrentInstance().getExternalContext(); // path is
> C:\glassfish3\glassfish\domains\domain1\applications\myapp String path =
> context.getRealPath("/"); File temp = new File(path, "summary.pdf");
>
>
> Is there a better place to store temporary files?
>
>
> You can use the *javax*.*servlet*.*context*.*tempdir* attribute (provided
> by the Servlet container, free of charge). The value of this attribute is
> of type File and is guaranteed to be a directory. When the application is
> undeployed, this should be cleaned up.
>
>
>
> --
>
> [Message sent by forum member 'hezjing']
>
> View Post: http://forums.java.net/node/804682
>
>
>
>


-- 
John Yeary
--
http://javaevangelist.blogspot.com
http://www.johnyeary.com
*_at_jyeary*
"Far better it is to dare mighty things, to win glorious triumphs, even
though checkered by failure, than to take rank with those poor spirits who
neither enjoy much nor suffer much, because they live in the gray twilight
that knows not victory nor defeat."
-- Theodore Roosevelt