You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Chris Pat <cp...@yahoo.com> on 2007/06/04 04:02:59 UTC

tomcat temp directory

Hello
How do I configure and access a temporary directory in Tomcat5x?  Oddly I am presently writing files I want to use immediately into java.io.tempdir and it works if I access the webapp from localhost.  However fails when accessed from a domain.  

Within the Action/servlet how to I write/read the context specific temp directory?  Is there a way to release the file lock that Tomcat will have on that file?  I close all streams, but in previous primitive way it held the lock and I had to stop/restart TC.  Any help along understanding this would be greatly appreciated.  

Re: tomcat temp directory

Posted by David Smith <dn...@cornell.edu>.
Tomcat doesn't have any config for the temp dir that I know of...it's 
more of a jvm thing.

I believe Sun's jvm is supposed to delete the file when it's associated 
file handle is gc'd.  Can you provide your OS, jdk and a chunk of sample 
code if how you are using the temp dir?  Also assuming the temp file is 
deleted when the file handle is gc'd, are you sure you aren't holding on 
to a reference somewhere?

As to localhost vs domain access, there should be no difference.  I'd 
assume it to be an issue with the connector config or how you are 
accessing the temp dir.

--David

Chris Pat wrote:
> Hello
> How do I configure and access a temporary directory in Tomcat5x?  Oddly I am presently writing files I want to use immediately into java.io.tempdir and it works if I access the webapp from localhost.  However fails when accessed from a domain.  
>
> Within the Action/servlet how to I write/read the context specific temp directory?  Is there a way to release the file lock that Tomcat will have on that file?  I close all streams, but in previous primitive way it held the lock and I had to stop/restart TC.  Any help along understanding this would be greatly appreciated.  
>
>   


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: tomcat temp directory

Posted by Tim Lucia <ti...@yahoo.com>.
I'm not sure what the impact of Tomcat is on this, but I've used syntax
similar to this:

try {
    File tf = File.createTempFile("pattern", ".suffix");
    tf.deleteOnExit();
    BufferedWriter out = new BufferedWriter(new FileWriter(tf));
    out.write("This temporary file is deleted on close");
    out.close();
} 
catch (IOException e) {
   ...
}

HTH,
Tim



> -----Original Message-----
> From: Chris Pat [mailto:cpanon@yahoo.com]
> Sent: Monday, June 04, 2007 6:38 AM
> To: Tomcat Users List
> Subject: Re: tomcat temp directory
> 
> Hi
> Further
> I see in catalina.bat where it is setup and all the defaults are
unchanged.
> This still does not explain why it is NOT putting the files in \temp and
> rather in just the root dir of the TC installation.  I could explicitly
> force it, however that doesnt seem right.
> 
> Chris Pat <cp...@yahoo.com> wrote: Hi Martin, David
> Thanks.
> Where/syntax to set the tmpdir?
> Below is the syntax I use and when run from local host it puts the files
> in the "root" tomcat directory, at the same level as the all the
> subdirectories.  Even outside the webapp directory.  However it is
> accessible.
> 
> When I switch to accessing from a domain with modjk, TC cant find the
file.
> The very same code that calls a servlet to populate a html img tag is
> blank, but the rest of the page renders correctly.
> 
> I also found something claiming that TC configures its own tmp directory
> per webapp.  Is that from the proper setting of CATALINA_TMPDIR in the
> server.xml?  with what syntax?  tia.
> 
> String tempdir = System.getProperty("java.io.tmpdir");
>       if (! (tempdir.endsWith("/") || tempdir.endsWith("\\"))) {
>         tempdir = tempdir + System.getProperty("file.separator");
>       }
>       File tempFile = null;
>       try {
>         tempFile = File.createTempFile("myFile", "." + outputType);
>       }
>       catch (IOException ex2) {
>       }
> 
> Martin Gainty  wrote: Hi Chris-
> did you set CATALINA_TMPDIR to your TOMCAT temp folder?
> M--
> This email message and any files transmitted with it contain confidential
> information intended only for the person(s) to whom this email message is
> addressed.  If you have received this email message in error, please
> notify
> the sender immediately by telephone or email and destroy the original
> message without making a copy.  Thank you.
> 
> ----- Original Message -----
> From: "Chris Pat"
> To: "Tomcat"
> Sent: Sunday, June 03, 2007 10:02 PM
> Subject: tomcat temp directory
> 
> 
> > Hello
> > How do I configure and access a temporary directory in Tomcat5x?  Oddly
> I
> > am presently writing files I want to use immediately into
> java.io.tempdir
> > and it works if I access the webapp from localhost.  However fails when
> > accessed from a domain.
> >
> > Within the Action/servlet how to I write/read the context specific temp
> > directory?  Is there a way to release the file lock that Tomcat will
> have
> > on that file?  I close all streams, but in previous primitive way it
> held
> > the lock and I had to stop/restart TC.  Any help along understanding
> this
> > would be greatly appreciated.
> >
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: tomcat temp directory

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Chris Pat [mailto:cpanon@yahoo.com] 
> Subject: RE: tomcat temp directory
> 
> Why however do I get null when I do the following?
>     File tempDir = (File) sc.getAttribute("workDir");
>     String tempDirStr = (String) sc.getAttribute("workDir");

The attribute name for the API is "javax.servlet.context.tempdir"; the
attribute name for the <Context> element in your Tomcat configuration is
"workDir".  You've confused the two.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: tomcat temp directory

Posted by Chris Pat <cp...@yahoo.com>.
Hi Chuck
Thankyou.
Why however do I get null when I do the following?  Should I be getting the context specific temp directory in the form of a directory or casted as a string?

ServletContext sc = getServlet().getServletContext();
    File tempDir = (File) sc.getAttribute("workDir");
    String tempDirStr = (String) sc.getAttribute("workDir");
    File tempFile = null;

"Caldarale, Charles R" <Ch...@unisys.com> wrote: > From: Chris Pat [mailto:cpanon@yahoo.com] 
> Subject: RE: tomcat temp directory
> 
> How do I get the servletContext within a method, within an 
> Action.

Assuming your code is part of a servlet, use the
GenericServlet.getServletContext() method.  If the servlet is hidden by
some framework, you'll have to look at the doc for that to figure out
how to retrieve the servlet object.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



RE: tomcat temp directory

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Chris Pat [mailto:cpanon@yahoo.com] 
> Subject: RE: tomcat temp directory
> 
> How do I get the servletContext within a method, within an 
> Action.

Assuming your code is part of a servlet, use the
GenericServlet.getServletContext() method.  If the servlet is hidden by
some framework, you'll have to look at the doc for that to figure out
how to retrieve the servlet object.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: tomcat temp directory

Posted by Chris Pat <cp...@yahoo.com>.
Hi Chuck
Great.  However may I ask the naive question?  
How do I get the servletContext within a method, within an Action.  Do I have to pass in the request, and dig it out from there?  tia.

"Caldarale, Charles R" <Ch...@unisys.com> wrote: > From: Chris Pat [mailto:cpanon@yahoo.com] 
> Subject: RE: tomcat temp directory
> 
> But how to I get at it programatically?  Is workDir an actual 
> context param that I can access and build a File from?

It's not a param, it's an attribute - read the servlet spec and the
servlet API doc.  Use the ServletContext.getAttribute() API to retrieve
the value of javax.servlet.context.tempdir, and then create files within
that directory as needed.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



RE: tomcat temp directory

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Chris Pat [mailto:cpanon@yahoo.com] 
> Subject: RE: tomcat temp directory
> 
> But how to I get at it programatically?  Is workDir an actual 
> context param that I can access and build a File from?

It's not a param, it's an attribute - read the servlet spec and the
servlet API doc.  Use the ServletContext.getAttribute() API to retrieve
the value of javax.servlet.context.tempdir, and then create files within
that directory as needed.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: tomcat temp directory

Posted by Chris Pat <cp...@yahoo.com>.
Hi Chuck
Thanks.
But how to I get at it programatically?  Is workDir an actual context param that I can access and build a File from?

"Caldarale, Charles R" <Ch...@unisys.com> wrote: > From: Chris Pat [mailto:cpanon@yahoo.com] 
> Subject: Re: tomcat temp directory
> 
> Or is there a better way to create a tmpdir  and random file 
> under the webapp.

Look at section 4.7.1 of the servlet spec:

"A temporary storage directory is required for each servlet context.
Servlet containers must provide a private temporary directory for each
servlet context, and make it available via the
javax.servlet.context.tempdir context attribute. The objects associated
with the attribute must be of type java.io.File."

You can use the workDir attribute of the  element if you don't
like the default:
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



RE: tomcat temp directory

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Chris Pat [mailto:cpanon@yahoo.com] 
> Subject: Re: tomcat temp directory
> 
> Or is there a better way to create a tmpdir  and random file 
> under the webapp.

Look at section 4.7.1 of the servlet spec:

"A temporary storage directory is required for each servlet context.
Servlet containers must provide a private temporary directory for each
servlet context, and make it available via the
javax.servlet.context.tempdir context attribute. The objects associated
with the attribute must be of type java.io.File."

You can use the workDir attribute of the <Context> element if you don't
like the default:
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: tomcat temp directory

Posted by David Smith <dn...@cornell.edu>.
Hmmmm...

I'm not sure why hitting the 8080 HTTP connector would act differently 
w/ respect to temp files than that 8009 AJP connector.

One thought that comes to mind is to have your own internal temp 
directory.  Since this won't be a real temp directory you will get the 
advantage of a folder that keeps files indefinitely (or at least long 
enough for the client to request them).  On the down side, it's up to 
you to manage name conflicts and delete the files.  The servlet handing 
out files can just delete them once they are requested.  For the minor 
number of files that get abandon (client aborts the page load), you 
might want to consider the Quartz project for running a timed thread to 
kill all the files that are older than say 12 hours.

--David

Chris Pat wrote:

>Hi David
>Thanks for further engaging this with me.  
>Yes, I am creating the file in an Action, dropping it in the tmpdir and reading it with a jsp that calls a servlet that reads the parameters and displays.  
>
>What I find odd is everything works perfectly when executed from localhost:8080...  However fails when accessed from a domain setup to pass *.do, *.jsp through modjk to TC.  
>
>I know for a fact, from the timestamp and opening the file that Action is creating the file correctly, the servlet is just not finding it...when accessed from a domain/modjk.  But again it works, inscrutably, perfectly when accessed from localhost on the same server.  I can even simultaneously switch between it succeeding on localhost and failing on domain multiple times with the same running instance of TC. 
>
>Or is there a better way to create a tmpdir  and random file under the webapp.  I am loathe to do that as I want to keep it possible for the admin to just delete the files in the root \temp or make it a task.  I dont want to get access into the webapp.
>
>David Smith <dn...@cornell.edu> wrote: In the code below, let's just ignore the logic for the string 'tempdir' 
>... looks like noise to me as it isn't used in the creation of a file.
>
>The call to create the temp file looks good and should store it in the 
>path specified by java.io.tmpdir.  You can write out the system property 
>to see where your files are going ... by default I think it's usually 
>the system temp.  My install of tomcat 5.5 as a service explicitly set's 
>it to the temp directory within the tomcat folder.  You can look for it 
>in your .bat files by looking for -Djava.io.tmpdir=
>
>Could you expand on this image tag generation?  Looks like you are 
>attempting to generate a temp image in a jsp and keep it long enough to 
>return it via servlet.  Those are two separate requests (page and image) 
>and it may already be gone by the time the client requests the image 
>itself if that's the case.
>
>--David
>
>Chris Pat wrote:
>
>  
>
>>Hi
>>Further
>>I see in catalina.bat where it is setup and all the defaults are unchanged.  This still does not explain why it is NOT putting the files in \temp and rather in just the root dir of the TC installation.  I could explicitly force it, however that doesnt seem right.  
>>
>>Chris Pat  wrote: Hi Martin, David
>>Thanks.
>>Where/syntax to set the tmpdir?
>>Below is the syntax I use and when run from local host it puts the files in the "root" tomcat directory, at the same level as the all the subdirectories.  Even outside the webapp directory.  However it is accessible.
>>
>>When I switch to accessing from a domain with modjk, TC cant find the file.  The very same code that calls a servlet to populate a html img tag is blank, but the rest of the page renders correctly.  
>>
>>I also found something claiming that TC configures its own tmp directory per webapp.  Is that from the proper setting of CATALINA_TMPDIR in the server.xml?  with what syntax?  tia.
>>
>>String tempdir = System.getProperty("java.io.tmpdir");
>>     if (! (tempdir.endsWith("/") || tempdir.endsWith("\\"))) {
>>       tempdir = tempdir + System.getProperty("file.separator");
>>     }
>>     File tempFile = null;
>>     try {
>>       tempFile = File.createTempFile("myFile", "." + outputType);
>>     }
>>     catch (IOException ex2) {
>>     }
>>
>> 
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To start a new topic, e-mail: users@tomcat.apache.org
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
>  
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: tomcat temp directory

Posted by Chris Pat <cp...@yahoo.com>.
Hi David
Thanks for further engaging this with me.  
Yes, I am creating the file in an Action, dropping it in the tmpdir and reading it with a jsp that calls a servlet that reads the parameters and displays.  

What I find odd is everything works perfectly when executed from localhost:8080...  However fails when accessed from a domain setup to pass *.do, *.jsp through modjk to TC.  

I know for a fact, from the timestamp and opening the file that Action is creating the file correctly, the servlet is just not finding it...when accessed from a domain/modjk.  But again it works, inscrutably, perfectly when accessed from localhost on the same server.  I can even simultaneously switch between it succeeding on localhost and failing on domain multiple times with the same running instance of TC. 

Or is there a better way to create a tmpdir  and random file under the webapp.  I am loathe to do that as I want to keep it possible for the admin to just delete the files in the root \temp or make it a task.  I dont want to get access into the webapp.

David Smith <dn...@cornell.edu> wrote: In the code below, let's just ignore the logic for the string 'tempdir' 
... looks like noise to me as it isn't used in the creation of a file.

The call to create the temp file looks good and should store it in the 
path specified by java.io.tmpdir.  You can write out the system property 
to see where your files are going ... by default I think it's usually 
the system temp.  My install of tomcat 5.5 as a service explicitly set's 
it to the temp directory within the tomcat folder.  You can look for it 
in your .bat files by looking for -Djava.io.tmpdir=

Could you expand on this image tag generation?  Looks like you are 
attempting to generate a temp image in a jsp and keep it long enough to 
return it via servlet.  Those are two separate requests (page and image) 
and it may already be gone by the time the client requests the image 
itself if that's the case.

--David

Chris Pat wrote:

>Hi
>Further
>I see in catalina.bat where it is setup and all the defaults are unchanged.  This still does not explain why it is NOT putting the files in \temp and rather in just the root dir of the TC installation.  I could explicitly force it, however that doesnt seem right.  
>
>Chris Pat  wrote: Hi Martin, David
>Thanks.
>Where/syntax to set the tmpdir?
>Below is the syntax I use and when run from local host it puts the files in the "root" tomcat directory, at the same level as the all the subdirectories.  Even outside the webapp directory.  However it is accessible.
>
>When I switch to accessing from a domain with modjk, TC cant find the file.  The very same code that calls a servlet to populate a html img tag is blank, but the rest of the page renders correctly.  
>
>I also found something claiming that TC configures its own tmp directory per webapp.  Is that from the proper setting of CATALINA_TMPDIR in the server.xml?  with what syntax?  tia.
>
>String tempdir = System.getProperty("java.io.tmpdir");
>      if (! (tempdir.endsWith("/") || tempdir.endsWith("\\"))) {
>        tempdir = tempdir + System.getProperty("file.separator");
>      }
>      File tempFile = null;
>      try {
>        tempFile = File.createTempFile("myFile", "." + outputType);
>      }
>      catch (IOException ex2) {
>      }
>
>  
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



Re: tomcat temp directory

Posted by David Smith <dn...@cornell.edu>.
In the code below, let's just ignore the logic for the string 'tempdir' 
... looks like noise to me as it isn't used in the creation of a file.

The call to create the temp file looks good and should store it in the 
path specified by java.io.tmpdir.  You can write out the system property 
to see where your files are going ... by default I think it's usually 
the system temp.  My install of tomcat 5.5 as a service explicitly set's 
it to the temp directory within the tomcat folder.  You can look for it 
in your .bat files by looking for -Djava.io.tmpdir=

Could you expand on this image tag generation?  Looks like you are 
attempting to generate a temp image in a jsp and keep it long enough to 
return it via servlet.  Those are two separate requests (page and image) 
and it may already be gone by the time the client requests the image 
itself if that's the case.

--David

Chris Pat wrote:

>Hi
>Further
>I see in catalina.bat where it is setup and all the defaults are unchanged.  This still does not explain why it is NOT putting the files in \temp and rather in just the root dir of the TC installation.  I could explicitly force it, however that doesnt seem right.  
>
>Chris Pat <cp...@yahoo.com> wrote: Hi Martin, David
>Thanks.
>Where/syntax to set the tmpdir?
>Below is the syntax I use and when run from local host it puts the files in the "root" tomcat directory, at the same level as the all the subdirectories.  Even outside the webapp directory.  However it is accessible.
>
>When I switch to accessing from a domain with modjk, TC cant find the file.  The very same code that calls a servlet to populate a html img tag is blank, but the rest of the page renders correctly.  
>
>I also found something claiming that TC configures its own tmp directory per webapp.  Is that from the proper setting of CATALINA_TMPDIR in the server.xml?  with what syntax?  tia.
>
>String tempdir = System.getProperty("java.io.tmpdir");
>      if (! (tempdir.endsWith("/") || tempdir.endsWith("\\"))) {
>        tempdir = tempdir + System.getProperty("file.separator");
>      }
>      File tempFile = null;
>      try {
>        tempFile = File.createTempFile("myFile", "." + outputType);
>      }
>      catch (IOException ex2) {
>      }
>
>  
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: tomcat temp directory

Posted by Chris Pat <cp...@yahoo.com>.
Hi
Further
I see in catalina.bat where it is setup and all the defaults are unchanged.  This still does not explain why it is NOT putting the files in \temp and rather in just the root dir of the TC installation.  I could explicitly force it, however that doesnt seem right.  

Chris Pat <cp...@yahoo.com> wrote: Hi Martin, David
Thanks.
Where/syntax to set the tmpdir?
Below is the syntax I use and when run from local host it puts the files in the "root" tomcat directory, at the same level as the all the subdirectories.  Even outside the webapp directory.  However it is accessible.

When I switch to accessing from a domain with modjk, TC cant find the file.  The very same code that calls a servlet to populate a html img tag is blank, but the rest of the page renders correctly.  

I also found something claiming that TC configures its own tmp directory per webapp.  Is that from the proper setting of CATALINA_TMPDIR in the server.xml?  with what syntax?  tia.

String tempdir = System.getProperty("java.io.tmpdir");
      if (! (tempdir.endsWith("/") || tempdir.endsWith("\\"))) {
        tempdir = tempdir + System.getProperty("file.separator");
      }
      File tempFile = null;
      try {
        tempFile = File.createTempFile("myFile", "." + outputType);
      }
      catch (IOException ex2) {
      }

Martin Gainty  wrote: Hi Chris-
did you set CATALINA_TMPDIR to your TOMCAT temp folder?
M--
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.

----- Original Message ----- 
From: "Chris Pat" 
To: "Tomcat" 
Sent: Sunday, June 03, 2007 10:02 PM
Subject: tomcat temp directory


> Hello
> How do I configure and access a temporary directory in Tomcat5x?  Oddly I 
> am presently writing files I want to use immediately into java.io.tempdir 
> and it works if I access the webapp from localhost.  However fails when 
> accessed from a domain.
>
> Within the Action/servlet how to I write/read the context specific temp 
> directory?  Is there a way to release the file lock that Tomcat will have 
> on that file?  I close all streams, but in previous primitive way it held 
> the lock and I had to stop/restart TC.  Any help along understanding this 
> would be greatly appreciated.
> 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org




Re: tomcat temp directory

Posted by Chris Pat <cp...@yahoo.com>.
Hi Martin, David
Thanks.
Where/syntax to set the tmpdir?
Below is the syntax I use and when run from local host it puts the files in the "root" tomcat directory, at the same level as the all the subdirectories.  Even outside the webapp directory.  However it is accessible.

When I switch to accessing from a domain with modjk, TC cant find the file.  The very same code that calls a servlet to populate a html img tag is blank, but the rest of the page renders correctly.  

I also found something claiming that TC configures its own tmp directory per webapp.  Is that from the proper setting of CATALINA_TMPDIR in the server.xml?  with what syntax?  tia.

String tempdir = System.getProperty("java.io.tmpdir");
      if (! (tempdir.endsWith("/") || tempdir.endsWith("\\"))) {
        tempdir = tempdir + System.getProperty("file.separator");
      }
      File tempFile = null;
      try {
        tempFile = File.createTempFile("myFile", "." + outputType);
      }
      catch (IOException ex2) {
      }

Martin Gainty <mg...@hotmail.com> wrote: Hi Chris-
did you set CATALINA_TMPDIR to your TOMCAT temp folder?
M--
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.

----- Original Message ----- 
From: "Chris Pat" 
To: "Tomcat" 
Sent: Sunday, June 03, 2007 10:02 PM
Subject: tomcat temp directory


> Hello
> How do I configure and access a temporary directory in Tomcat5x?  Oddly I 
> am presently writing files I want to use immediately into java.io.tempdir 
> and it works if I access the webapp from localhost.  However fails when 
> accessed from a domain.
>
> Within the Action/servlet how to I write/read the context specific temp 
> directory?  Is there a way to release the file lock that Tomcat will have 
> on that file?  I close all streams, but in previous primitive way it held 
> the lock and I had to stop/restart TC.  Any help along understanding this 
> would be greatly appreciated.
> 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



Re: tomcat temp directory

Posted by Martin Gainty <mg...@hotmail.com>.
Hi Chris-
did you set CATALINA_TMPDIR to your TOMCAT temp folder?
M--
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.

----- Original Message ----- 
From: "Chris Pat" <cp...@yahoo.com>
To: "Tomcat" <us...@tomcat.apache.org>
Sent: Sunday, June 03, 2007 10:02 PM
Subject: tomcat temp directory


> Hello
> How do I configure and access a temporary directory in Tomcat5x?  Oddly I 
> am presently writing files I want to use immediately into java.io.tempdir 
> and it works if I access the webapp from localhost.  However fails when 
> accessed from a domain.
>
> Within the Action/servlet how to I write/read the context specific temp 
> directory?  Is there a way to release the file lock that Tomcat will have 
> on that file?  I close all streams, but in previous primitive way it held 
> the lock and I had to stop/restart TC.  Any help along understanding this 
> would be greatly appreciated.
> 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org