Hi,

> -----Original Message-----
> From: Stephane Grialet [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 12, 2001 2:50 PM
> To: [EMAIL PROTECTED]
> Subject: Hello !
>
>
> I am a new user in this list, and i'm French so please forgive my
> mistakes !
>
> I am developing a project with Tomcat and servlets technology, and i
> have the following problem i would like to submit to you:
>
> I have a basic servlet S1 who includes several methods useful for all
> the other servlets.

Forget. Try ContextListener initializing a shared object and then
Context.setAttribute() it so it's available for whatever wants it. Of course
it requires Servlets 2.3, but it's worth it and Tomcat 4.0b5 is stable
enough for business use.

> The appli works fine... but suddenly, i get a loss of context that i
> can't explain.
> One of the servlets who calls a S1's method sees all the global
> variables have a NULL value, while a few moments before these values
> were correctly defined.
> These values are config parameters read from the web.xml file of the
> appli. They are initialized in the init() method of the S1 servlet.
>
> So i wonder what's going on...
> Is there any config or servlet memory timeout that raises ? or what ?...

As far as I know you can't make any assumptions about servlet timeouts and
reloading. At least you should not make them.

> It is a serious problem because all the application becomes
> unpredictably unusable, until i restart Tomcat.
>
> Here is a bit of my S1 servlet code :
>
> /**************************************************************
> public class S1 extends HttpServlet implements SingleThreadModel {
>
> private static String P1;
> ...
>
> //----------------------------------------------------------------
> --------------------
>
> // methode d'initialisation: recuperation des parametres de conf
> public void init(ServletConfig sc) throws ServletException {
>
>  if (sc == null) {
>  System.out.println("ServletConfig = null");
>  System.exit(1);
>  }

Using System.exit() is a very bad idea. No cleanup.

>
>  super.init(sc);
>  try {
>  P1 = sc.getInitParameter("P1");
> ...
>
>  if (P1 == null) {
>   System.out.println("Paramètres de configuration de l'application
> incorrectement renseignés.");
>   System.exit(1);
>  }
>  else System.out.println("Contexte Base de signalements chargé.");
>  }
>  catch (Exception e) {
>  e.printStackTrace();
>  System.out.println("Lecture des paramètres de configuration de
> l'application impossible.");
>  System.exit(1);
>  }
> }
>
> // method called by other servlets
> public String m1(ServletOutputStream out) {
>
> // uses init parameters such as P1 and returns a result
> ...
> }
> /**************************************************************
>
> thanks for any help
>
> Stéphane

Greetings, deacon Marcus

Reply via email to