Sam,

As init() is invoked only at servlet load time, one of its uses is to
allocate "global" resources which may be required across multiple service()
calls; destroy() allows you to release these resources cleanly when your
servlets are done.

While there are many cases where servlets don't need to grab such things at
load time, in the case you describe, you would probably want to use a
Database Connection Pool, managed by a (singleton) Pool Manager - and where
better acquire its reference but in the init() method!

Cheers,

Anthony

At 11:02 10/03/99 -0000, Sam Rose wrote:
>Hi,
>
>I was wondering which approach would be best for my servlet's that I
>am currently developing.
>All of the servlets connect to an Oracle database.
>
>I was wondering do I need to use an init() and destroy() in my coding,
>can I leave this out or would that be a bad idea? As couldn't I just
>use finally clause, or have I lost the plot altogether?
>
>Sam Rose
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>
******************************************
   Imperium Computing Consultants Ltd.

      Web and Database solutions at

       http://www.imperium.co.uk/
******************************************

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to