W
warth33
Hello
I have a web app that is composed by a lot of pages, page1, page2,
page3. Everypage is a servlet. The servlet will eventually redirect to
a jsp.
I am using jndi datasource, thats the first time. I managed
configuring server.xml, web.xml.
Now, in the servlet page1, in its init method, I have code like this:
Context env = (Context) new InitialContext().lookup("java:comp/env");
pool = (DataSource) env.lookup("jdbc/TestDB");
Later, in the doget, I do database operations. So it works so long.
But I am a little bit concerned about the other servlets. How can
servlet named page2, servlet named page3, and so on access the
database? Do they also need to have its own init method, and they also
need the code I showed above? maybe it has to be this way, but it
seems like you do the same job several times.
Isnt there a way to make all the webapp share the Connection pooling
that was created by a single servlet start?
I have a web app that is composed by a lot of pages, page1, page2,
page3. Everypage is a servlet. The servlet will eventually redirect to
a jsp.
I am using jndi datasource, thats the first time. I managed
configuring server.xml, web.xml.
Now, in the servlet page1, in its init method, I have code like this:
Context env = (Context) new InitialContext().lookup("java:comp/env");
pool = (DataSource) env.lookup("jdbc/TestDB");
Later, in the doget, I do database operations. So it works so long.
But I am a little bit concerned about the other servlets. How can
servlet named page2, servlet named page3, and so on access the
database? Do they also need to have its own init method, and they also
need the code I showed above? maybe it has to be this way, but it
seems like you do the same job several times.
Isnt there a way to make all the webapp share the Connection pooling
that was created by a single servlet start?