G
GaryM
I have a question that relates to a web application I deployed under
Jetty, but more generally, has highlighted a misconception I have held
on static classes.
I have implemented the Jakarta Commons Database Connection Pooling. To
facilate the web app, I wrote a class with static methods to provide,
amongst other things, a connection from the pool. I initialize the
static class in the main app, then start the Jetty Server.
My rationale was that the static class would be subsequently accessable
to the Jetty server as they are all under one VM. I was surprised that
this was not the case and in fact I needed to initialize the static
class in the web app itself. If I simply add a context (as opposed to a
Web Application) to the server this approach works.
So my questions are:
1. How does this work, ie. how is possible to limit the scope of static
class? Is a new VM created to run the web app?
2. Is there a recommended method for initialzing the web app aside from
checking for initialization in every JSP?
Jetty, but more generally, has highlighted a misconception I have held
on static classes.
I have implemented the Jakarta Commons Database Connection Pooling. To
facilate the web app, I wrote a class with static methods to provide,
amongst other things, a connection from the pool. I initialize the
static class in the main app, then start the Jetty Server.
My rationale was that the static class would be subsequently accessable
to the Jetty server as they are all under one VM. I was surprised that
this was not the case and in fact I needed to initialize the static
class in the web app itself. If I simply add a context (as opposed to a
Web Application) to the server this approach works.
So my questions are:
1. How does this work, ie. how is possible to limit the scope of static
class? Is a new VM created to run the web app?
2. Is there a recommended method for initialzing the web app aside from
checking for initialization in every JSP?