aspose file tools*
The moose likes Tomcat and the fly likes Is running a servlet from the startup script possible Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Is running a servlet from the startup script possible" Watch "Is running a servlet from the startup script possible" New topic
Author

Is running a servlet from the startup script possible

Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 579
When I run the startup script I would like to run a servlet that would set up a number of connections to a database.
So when the web application is up and running I would already have stored a number of database connections in the servlet contex.
Is this possible or can I only run a servlet when the web application is up and running.
What I am trying to achieve is with the connections established when someone l;ogs in they dont have to wit for the servlet to connect to the database.
Thanks for any help.
Tony
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
You can use the init() method of the servlets to set this up. The init() is called when the web application is first loaded, so by the time a request is actually handled, everything can be ready to go -- nice and fast.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 579
Thanks Nathaniel, got it working.
Cheers Tony
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
My pleasure, Tony. How about putting me on the payroll? :roll:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is running a servlet from the startup script possible