开发者

Java equivalent to ASP.NET global.Asax

Hi I am new to java and I am developing a java web 开发者_开发百科application i would like to run some code at application start up. In .Net i would use the global.asax file, how can i do this in java.

Thanks for any help


I prefer to implement a listener for initialization, but that is just me. Extend javax.servlet.ServletContextListener then configure your listener class in the web.xml file.


If I understood you correctly, What you're looking for is web.xml (What is called Deployment Descriptor). There are many examples on Google that can show you how.

For "application startup", you would have to write a servlet that initializes your application (but I'm unclear as to what you mean "run code at application startup").

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜