Linux -Blue forest free software | Return to home page | Site Map | Search WWW | Contact Us |
Your current position : Homepage > Free Software > Technological exchanges >Application Programming


    

Blue Forest http://www.lslnet.com at 10:18 on June 6, 2006


Servlet problems

TOMCAT months in a Web application, and want to TOMCAT loaded in the application, automatically loading a servlet, and the operation of certain way (for variable initialized to the whole, such as the database connection pool removed the data source object and preservation), it should be how do?

Servlet problems

Put an object inside a structure, the sound of static objects.
Public class commonvalue{
String aa;
String bb;
Private static commonvalue commonvalue instance = new ();
Boolean inited;
Static commonvalue getinstance () (
If (flag) (
Return instance;
}else{
Commonvalue instance = new ();
4003rd initialization of variables.
4003rd return
Return instance;

       }

    }

        /**
*return
         */
Public String getAa () (
Return aa;
        }

        /**
*return
         */
Public String getBb () (
Return bb;
        }

        /**
*param String
         */
Public void setAa (String string) (
Aa = string;
        }

        /**
*param String
         */
Public void setBb (String string) (
Bb = string;
        }
}
Then getinstance () below.

This is required?

Servlet problems

Thank you.
The question is how will be able to use its Web application loaded automatically loaded?

Servlet problems

Init

Servlet problems

This is the first visit when loading
If you want to start service in the loading web.xml Lane should have a label to handle.
For example, the tomcat conf\\web.xml Lane
[code]
"Servlet>;
"Servlet-name>;invoker</servlet-name>;
"Servlet-class>;
Org.apache.catalina.servlets.InvokerServlet
"/servlet-class>;
"Init-param>;
"Param-name>;debug</param-name>;
"Param-value>;0</param-value>;
"/init-param>;
"Load-on-startup>;2</load-on-startup>;
"/servlet>;
[/code]
Load-on-startup designated start is the type of loading.

Servlet problems

Try first, I would like to thank first

Servlet problems

In web.xml configuration file
"Servlet>;
"Servlet-name>;Sname</servlet-name>;
               
"Servlet-class>;test.Sname</servlet-class>;
"Load-on-startup>;1</load-on-startup>;
               
"/servlet>;

Servlet problems

OK, 3x



 Privacy Policy  Copyright © 1999-2000 LSLNET.COM. All rights reserved. Blue Forest website owners. E-mail : Webmaster@lslnet.com