• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Why is my servlet loaded twice?

 
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have my servlet set to:
<load-on-startup>1</load-on-startup>
and it prints out "Loaded!" when it's loaded. This prints TWICE when I start up the server - why is this? (I'm using tomcat 3.2.3 if it's only with that servlet engine that this occurs)
 
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Robert
It may be that the servlet container created more than one instance of your servlet. I believe it may do this if you implement the SingleThreadModel interface, or under some or other condition where it determines that having only one servlet instance to service requests may degrade overall performance.
Mark.
 
Mark Howard
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On further investigation, it appears the container may create multiple servlet instances only if the servlet implements the SingleThreadModel interface.
 
Robert Paris
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interesting!
1. How does the SingleThreadedModel vs the alternative affect everything? (for example static variables)
2. How do I set the thread model to use?
 
author
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the same issue. My servlet does not implement SingleThreadModel, so I don't think that's the reason in this case.
David
 
Doody calls. I would really rather that it didn't. Comfort me wise and sterile tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic