You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Christian Hvid <ch...@acm.org> on 2003/06/27 20:34:26 UTC

"Persistent attributes"

Hello list.

I have tried posting this question to comp.lang.java but I didn't get 
the answer that I needed:

I am writing a web application that stores its data in an XML-file. I 
am deploying it via Apache Tomcat. I would like to make it easy to 
deploy. For it to work the user deploying my application has to set the 
file name of the data storage.

I can think of two approaches:

1. The application provides the user interface: My application has a 
setup page and if it is the first time it is run it will ask the user 
the file name of the data storage.

To implement this I need to make a string persistent. Does Apache 
Tomcat provide a way to make data persistent accross stop/starts? I 
have tried setAttribute in ServletContext but the attributes disappear 
when the application is reloaded.

2. The servlet container provides the user interface: I find the Tomcat 
web interface slightly clumsy but there is something called environment 
entries in the administration tool. How do I read these environment 
entries in my application?

Alternatively: Is there a way to set the init parameters (that are read 
via ServletConfig) from within Apache Tomcat's web interface?

Any help appreciated.

-- Christian

PS: If you are interested - I am making a Wiki and it is available 
including source here:

http://vredungmand.dk/programming/orange/index.html


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


RE: "Persistent attributes"

Posted by Mike Curwen <gb...@gb-im.com>.
The way I'd do this is to use Properties objects, and a few (perhaps
even one?) files under WEB-INF/props
 
On startup, on the setup page, you'd ask the user to supply the filepath
to use.
Then you'd write that info to WEB-INF/props/application.properties.

On subsequent restarts, your app looks to this file to "remember" where
its stuff is, and can load the values into an appropriate area (like
ServletContext)

> -----Original Message-----
> From: Christian Hvid [mailto:chvid@acm.org] 
> Sent: Friday, June 27, 2003 1:34 PM
> To: tomcat-user@jakarta.apache.org
> Subject: "Persistent attributes"
> 
> 
> Hello list.
> 
> I have tried posting this question to comp.lang.java but I didn't get 
> the answer that I needed:
> 
> I am writing a web application that stores its data in an XML-file. I 
> am deploying it via Apache Tomcat. I would like to make it easy to 
> deploy. For it to work the user deploying my application has 
> to set the 
> file name of the data storage.
> 
> I can think of two approaches:
> 
> 1. The application provides the user interface: My application has a 
> setup page and if it is the first time it is run it will ask the user 
> the file name of the data storage.
> 
> To implement this I need to make a string persistent. Does Apache 
> Tomcat provide a way to make data persistent accross stop/starts? I 
> have tried setAttribute in ServletContext but the attributes 
> disappear 
> when the application is reloaded.
> 
> 2. The servlet container provides the user interface: I find 
> the Tomcat 
> web interface slightly clumsy but there is something called 
> environment 
> entries in the administration tool. How do I read these environment 
> entries in my application?
> 
> Alternatively: Is there a way to set the init parameters 
> (that are read 
> via ServletConfig) from within Apache Tomcat's web interface?
> 
> Any help appreciated.
> 
> -- Christian
> 
> PS: If you are interested - I am making a Wiki and it is available 
> including source here:
> 
http://vredungmand.dk/programming/orange/index.html


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


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