On 14 Aug 2002, Stephen Bacon wrote:
> Date: 14 Aug 2002 11:09:16 -0400
> From: Stephen Bacon <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: Tomcat Users List <[EMAIL PROTECTED]>
> Subject: RE: Writing files from a class
>
> Thanks for the reply,
>
> I see that the spec mentions "private temporary directory" - I need a
> permananent directory - by temporary I take it to mean that I can't
> count on the files "sticking around". Is my understanding here flawed?
>
No, you've got it right. There is no current portable mechanism for
per-webapp persistent file storage. Options include:
* Pass the pathname to a directory in an init parameter
* Store stuff in a database/directory server instead
* On JDK 1.4, consider using the new Preferences API
(java.util.prefs) for storing stuff.
> Also, I'd like to be able to specify the name and location.
> I had seen the javax.servlet.ServletContext.log() methods, but they seem
> to offer no control over where the output is placed. I'd rather have a
> debug file per class than have all messages sent to a single file.
>
Mapping of ServletContext.log() calls to particular destinations is
specific to the server you are using. For Tomcat 4, you can use <Logger>
elements to have log files per-webapp, per-host, or per-server, but not
per-caller (which makes sense -- how is the log() method supposed to know
who the caller is)?
For finer grained debugging-type logging, I'd suggest looking at things
like Log4J or the JDK 1.4 logging methods.
> And finally, I have servlets that take data from a db and place it in a
> (text) file for the user to download - so once again a file creation
> issue where I need a general file i/o solution.
>
Is there a particular reason that you make it a file instead of just
grabbing the data from the database every time? Or, for performance,
caching it in memory at app startup and just serving the characters out of
a saved String or something?
After all, the client has no way of knowing whether a request URL like
"/foo/bar/baz.html" was really a static resource or not.
> thanks,
> -Steve
Craig
>
> On Tue, 2002-08-13 at 20:15, Sexton, George wrote:
> > >From the servlet 2.3 Specification:
> >
> > SRV.3.7.1 Temporary Working Directories
> >
> > A temporary storage directory is required for each servlet context. Servlet
> > containers must provide a private temporary directory per 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.
> >
> >
> > -----Original Message-----
> > From: Stephen Bacon [mailto:[EMAIL PROTECTED]]
> > Sent: 13 August, 2002 5:20 PM
> > To: [EMAIL PROTECTED]
> > Subject: Writing files from a class
> >
> >
> > Hello,
> > I'm trying to migrate from Tomcat 3 to Catalina (under Linux) and I've
> > hit a snag. Several of my custom classes which I use from JSPs (e.g.
> > ConnectionPool) print messages to debug files which I access via:
>
> <snip>
>
>
>
> --
> 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]>