开发者

initialize ServletContext using a method on a Resin server

开发者 https://www.devze.com 2022-12-17 15:46 出处:网络
Is there a way to initialize 开发者_Python百科the ServletContext for a webapp on a Resin server using a method? I need something likethat runs once, when the server starts up.You need to use a Servlet

Is there a way to initialize 开发者_Python百科the ServletContext for a webapp on a Resin server using a method? I need something like that runs once, when the server starts up.


You need to use a ServletContextListener.

http://www.java-tips.org/java-ee-tips/java-servlet/how-to-work-with-servletcontextlistener.html

This J2EE tip demonstrates use of ServletContextListener. This event class handles notifications about changes to the servlet context of the Web application that they are part of. This can be explained as if someone is present on the server and dynamically informing us about the events that are occuring on the server. There acquire need of Listners. Therefore, ServletContextListner is helpful in informing about context Initilazation and destruction.


Use the <load-on-startup/> in the <servlet> tag.

0

精彩评论

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