开发者

web.xml load class on startup into context

I have a class that I want to instantiate at startup. It does concurrent stuff and has开发者_如何学编程 to be visible for all incoming requests. Placing it in the ServletContext should be the right way to go.

I don't care about bottlenecks, all requests have to work on the same data.

But how can I tell my Webserver to load this class once at startup and place it into the context?

For Strings there is the setInitParameter, but can't we do the same for objects?


You might want to look at a ServletContexListener and store your Object in context when the context is initalized. You can get the ServletContext from the passed ServletContextEvent.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜