You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by po...@purplevillage.com on 2002/09/24 17:26:20 UTC

Locating Dynamically Generated Files...

My JSP uses a bean that creates a file dynamically.
Unfortunately, the file ends up in the jakarta-tomcat\bin directory rather than 
in my web app directory where the JSP tries to get it from.

How do I make dynamically generated files end up in my web app directory?
Anyone run across any sample code that does this?

Thanks...

Jerry


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Locating Dynamically Generated Files...

Posted by Jacob Kjome <ho...@visi.com>.
Are you saying that you want to create files and leave them in a place
on the web where someone can get them at a future date, or is this
just a dynamic file for this user for this particular download?  You
probably just want to stream the file to them and not create it on
disk.  You should avoid File IO as much as possible because there is
no guarantee in the servlet spec that you have write access to your
application other than the tempdir:
File temp = (File)context.getAttribute("javax.servlet.context.tempdir");

you can write it there, do stuff with it and then stream it to the
user.  If you really do have to write files to your webapp, then make
double sure that the user running Tomcat has permission to write files
to your webapp's directory and make sure that you deploy a directory
rather than a .war file.  If you run the app from a .war file, you
will have *no* file system access to your webapp.

Jake


Tuesday, September 24, 2002, 10:26:20 AM, you wrote:

ppc> My JSP uses a bean that creates a file dynamically.
ppc> Unfortunately, the file ends up in the jakarta-tomcat\bin directory rather than 
ppc> in my web app directory where the JSP tries to get it from.

ppc> How do I make dynamically generated files end up in my web app directory?
ppc> Anyone run across any sample code that does this?

ppc> Thanks...

ppc> Jerry


ppc> --
ppc> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
ppc> For additional commands, e-mail: <ma...@jakarta.apache.org>



-- 
Best regards,
 Jacob                            mailto:hoju@visi.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Locating Dynamically Generated Files...

Posted by Adam Greene <ag...@romulin.com>.
You could use the servlet context's getRealPath().  I'm not sure the exact
name of the class (I use Tapestry for all my web development and it accesses
it as getServletContext().getRealPath()).

-----Original Message-----
From: postmaster@purplevillage.com [mailto:postmaster@purplevillage.com]
Sent: Tuesday, September 24, 2002 12:26 PM
To: tomcat-user@jakarta.apache.org
Cc: jer@purplevillage.com
Subject: Locating Dynamically Generated Files...


My JSP uses a bean that creates a file dynamically.
Unfortunately, the file ends up in the jakarta-tomcat\bin directory rather
than
in my web app directory where the JSP tries to get it from.

How do I make dynamically generated files end up in my web app directory?
Anyone run across any sample code that does this?

Thanks...

Jerry


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>