Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

web.xml autorun

 
Ryan Bailey
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know how to have tomcat auto start a servlet once the tomcat service is started.
I found that if I include
<load-on-startup>1</load-on-startup>
for my servlet in my xml that would work. But I have also read that this can cause complications.
Ok here is my web.xml file

I was told the lower the number takes precedence in <load-on-startup>
My code is as follows

Neither one of my sys.out statements are being called.
Any suggestions? I would like to make a timed thread execute once tomcat is started. I am using tomcat 4.1
Thanks in advance for your time,
Ryan
 
Asher Tarnopolski
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<load-on-startup> work fine by me.
to make servlet be initialized first you should put the value of 1 , not -1.
try it.
 
Ryan Bailey
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Someone please help!!
I have double checked my code and web.xml file and I still do not understand why I am not seeing an output of hello once I start the servlet engine. I thought maybe it was a configuration at work, but I tried testing this case at home and I'm still having the same issue. If anyone could lead me into the right direction it would be very appriciated.
Thank you,
Ryan
 
Ryan Bailey
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, NEVERMIND!!
I figured it out. Who ever told me that negative numbers took precedence over positive number it full of you know what. I changed my negative number to a positive number and it worked just fine. Sorry for sounding so desperate but I was really starting to not understand why this wasn't working.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic