tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Jacobson <marti...@libero.it>
Subject Re: session startup
Date Thu, 21 Nov 2002 09:24:50 GMT
Paul_Wallace@allsolutions.com.au wrote:
> OK, 
>         Perhaps then a session is not what is required here. I wish to 
> make available upon startup of the server, some simple string values. They 
> must be accessible to all clients, auto initialised when the service 
> starts up. This is something similar to a posting I made a while ago 
> reagrding libraries. I want to load into memory these values when the 
> server starts, that will be accessible to all clients.
> 
> Thanks
> 
> Paul.
>  

You need to implement a ContextListener class. Here's a snippet of what 
I have:

1) Java:

package com.terma.martin.drs.util;

import java.io.*;
import java.util.*;
import javax.servlet.*;

public class ApplicationInitializer implements ServletContextListener
{
	public void contextInitialized(ServletContextEvent sce)
	{
		ServletContext ctx = sce.getServletContext();

		String propsFileName = ctx.getInitParameter("props-file");

... etc.

2) web.xml:
<web-app>
	<context-param>
		<param-name>props-file</param-name>
		<param-value>/WEB-INF/app.properties</param-value>
	</context-param>

	<listener>
	 
<listener-class>com.terma.martin.drs.util.ApplicationInitializer</listener-class>
	</listener>

HTH

Martin


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


Mime
View raw message