File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Multiple Servlet Objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Multiple Servlet Objects" Watch "Multiple Servlet Objects" New topic

Multiple Servlet Objects

Sandeep Vaid
Ranch Hand

Joined: Feb 27, 2006
Posts: 392
If we define multiple <servlet> elements of same SERVLET in web.xml, then web contianer will create multiple Servlet Objects. Right?

This may be useful for example you may want one instance to connect to one database and second instance to connect to another database...
Rishi Chopra
Ranch Hand

Joined: Mar 07, 2004
Posts: 108
hi yes you are right one first point

but i dont agree on the fact that you are thinking of making two instances of one servlet merely to connect to two different databases .


Life is Beautiful Learn to See it.........
Jon Lee
Ranch Hand

Joined: Mar 04, 2005
Posts: 134
Database connection should be an plain old Java object.

SCJP 5.0 - 98% (2007)<br />SCWCD 1.4 - 97% (2007)
Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
yes....keeping in mind the design patterns the database connection should be done in a model and not in a controller.. !

SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]
Performance is a compulsion, not a option, if my existence is to be justified.
I agree. Here's the link:
subject: Multiple Servlet Objects
It's not a secret anymore!