开发者

start all servlets at application launch

开发者 https://www.devze.com 2023-04-13 04:51 出处:网络
I have a web application which has two servlets that exchange information through context attributes.

I have a web application which has two servlets that exchange information through context attributes.

Each servlet开发者_如何学C depends on the information that the other servlet sets in the context attributes. For example if I first access servlet S1, I need to access information that is provided by servlet S2, through context attributes, I make a request (through URLConnection) to S2.

I need servlets S1 and S2 to start (be initialized) at application launch, not when a request is made to them.

Is there any configuration I can make, so that all servlets in my application are initialized at launch time?


In web.xml (the deployment descriptor):

<servlet>
    <servlet-name>SomeServlet</servlet-name>
    <servlet-class>com.example.SomeServlet</servlet-class>
    <load-on-startup>1</load-on-startup> <!-- this is the element -->
</servlet>

Explanations:

  • What does the servlet <load-on-startup> value signify
  • http://geekexplains.blogspot.com/2008/06/what-does-load-on-startup-element-mean.html
  • http://wiki.metawerx.net/wiki/Web.xml.LoadOnStartup
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号