This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

How to configure Tomcat to load a servlet  RSS feed

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i m using Tomcat. Can any one tell me or sent me some url where i can get some information to configure Tomcat so that it will lode a specified servlet when it is started .
Need help desperately....
With regards
Arunabh
 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't think this functionality was vendor specific.
I usually just use the <load-on-startup> subelement of <servlet>
As in:

<servlet>
...servlet stuff
<load-on-startup>5</load-on-startup>
</servlet>

The value you pass being the load priority.
 
Rancher
Posts: 42975
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Servlet API 2.3 introduced lifecycle events, which are a better solution to this (specifically, contextInitialized and contextDestroyed). Using a servlet purely for application initialization is kind of a hack.
 
Arunabh Dash
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for ur reply.
Where i have to set it. In the web.xml or some where in the servlet.
With regards
Arunabh
 
Author and ninkuma
Marshal
Posts: 66804
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

thank you for ur reply.



Pleae use real words.
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In web.xml within the servlet tag put <load-on-startup> tag with a numeric value specifying the order in which the servlet should be loaded.

Example -
<servlet id="Servlet_26">
<servlet-name>NbaStartupServlet</servlet-name>
<servlet-class>com.mine.StartupServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

If you have more than one servlets to load on startup, you can use int value 2,3,... to specify the order in which the servlets should load at startup.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!