You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Benson Margulies <bi...@gmail.com> on 2011/11/25 22:24:16 UTC

Minimal persistent storage for a webapp

I'm fairly certain that I know the answer to the question here, but I
want to pose it just in case I've missed something.

In a web application, I'd like to store a bit of data without
configuring a database, or, indeed anything that has to be edited into
an XML file or typed into a container-level gui. As far as I know, the
entire servlet/webapp spec has nothing for me here, since the Snoracle
thinking was that this sort of thing was the job of JEE descriptors.

Have I missed something all these years?

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


Re: Minimal persistent storage for a webapp

Posted by Konstantin Kolinko <kn...@gmail.com>.
2011/11/26 Benson Margulies <bi...@gmail.com>:
> On Fri, Nov 25, 2011 at 4:36 PM, Konstantin Kolinko
> <kn...@gmail.com> wrote:
>> 2011/11/26 Benson Margulies <bi...@gmail.com>:
>>>
>>> In a web application, I'd like to store a bit of data without
>>> configuring a database, or, indeed anything that has to be edited into
>>> an XML file or typed into a container-level gui.
>>
>> Define "store". What is proposed lifetime of that information?
>
> Forever. Sorry about the snide vendor remark. I have to think about
> whether redeployment is good enough. Is that ServletContext.TEMPDIR
> guaranteed to stick around across container reboots as long as the app
> isn't specifically redeployed?
>

If autodeployment is enabled just touching the war etc. (and since
7.0.23 just touching conf/context.xml) while Tomcat is running will
cause redeployment of a web application. The content of the
ServletContext.TEMPDIR directory will be cleared at that time. It
might be not what you want.

Best regards,
Konstantin Kolinko

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


Re: Minimal persistent storage for a webapp

Posted by Benson Margulies <bi...@gmail.com>.
On Fri, Nov 25, 2011 at 4:36 PM, Konstantin Kolinko
<kn...@gmail.com> wrote:
> 2011/11/26 Benson Margulies <bi...@gmail.com>:
>> I'm fairly certain that I know the answer to the question here, but I
>> want to pose it just in case I've missed something.
>>
>> In a web application, I'd like to store a bit of data without
>> configuring a database, or, indeed anything that has to be edited into
>> an XML file or typed into a container-level gui. As far as I know, the
>> entire servlet/webapp spec has nothing for me here, since the Snoracle
>> thinking was that this sort of thing was the job of JEE descriptors.
>>
>> Have I missed something all these years?
>>
>
> Define "store". What is proposed lifetime of that information?

Forever. Sorry about the snide vendor remark. I have to think about
whether redeployment is good enough. Is that ServletContext.TEMPDIR
guaranteed to stick around across container reboots as long as the app
isn't specifically redeployed?

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


Re: Minimal persistent storage for a webapp

Posted by Konstantin Kolinko <kn...@gmail.com>.
2011/11/26 Benson Margulies <bi...@gmail.com>:
> I'm fairly certain that I know the answer to the question here, but I
> want to pose it just in case I've missed something.
>
> In a web application, I'd like to store a bit of data without
> configuring a database, or, indeed anything that has to be edited into
> an XML file or typed into a container-level gui. As far as I know, the
> entire servlet/webapp spec has nothing for me here, since the Snoracle
> thinking was that this sort of thing was the job of JEE descriptors.
>
> Have I missed something all these years?
>

Define "store". What is proposed lifetime of that information?

You can store anything in memory, using static variables (as each
webapp has its own class loader), or even use
ServletContext.setAttribute().

There are writable directories:
 (a) application-specific one that is cleared on redeployments
(work/appname in Tomcat),
 (b) java.io.tmpdir as well as user home directory.

(a) is required by Servlet spec and there is standard ServletContext
attribute that provides path of that directory. See
ServletContext.TEMPDIR constant.

> Snoracle thinking

JCP was community effort...


Best regards,
Konstantin Kolinko

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