This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
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

GenericServlet.Init()

 
Ryan Bailey
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having some trouble using the init method. In my web.xml file I am setting load-on-startup to 1. So when I startup my servlet engine my servlet with the load-on-startup paramter will start up. This is working just fine. The init method gets called and starts executing the code in the body. However, I am calling another method of another class that simply prints out a message to the screen. This method does not seem to be getting called. It's like it just jumps right over the method call and continues to load the servlet engine. below is my code example that I'm executing.


Hi 1 is getting executing, but when calling the TemperatureTimer constructor, Hi 2 is not getting called. Why is this? I can't figure this out if my life depended on it.
I want to write a Servlet that gets instantiated automatically when the servlet engine starts. The TemperatureTimer does implement Runnable. I'm reading temperatures via iButtons, but can't seem to instantiate the darn TemperatureTimer class. I even had the TemperatureTimer class methods inside the servlet class. Still no methods were getting called. I'm sure it's something easy that I'm just overlooking.
Thanks in advance for you time,
Ryan
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first thing I would do is enclose the call to the TemperatureTimer constructor in a try{}catch{} to see if the statement is throwing some exception such as class not found.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic