• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to make servlet able to run as soon as computer started

 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,,

its very urgent can any body tell me ..how to deploy the servlet so that every time the computer is on/swithed on , srevlet and obviously ( tomcat container ) starts automatically ..
i m using windows 2k ...
i know i have to make entry in some batch file but what entry ?

pls tell me where to put the servlet so that it runs automatically

thanx and regards,
amit
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you install Tomcat as a Windows service and use

in your servlet declaration in web.xml it will do that.

PS: If this servlet is only being used for startup configurations, you would be better off using a ContextListener.
 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx a ton
can u pls tell me why we use contextlistner in this case ? what is that about ?

but how to use contextlistner ?
i mean what entries to be done in that ???

can u pls write some thing so that i should copy to that ...
actually i don't have much time..

regards,
amit
 
Malli Raman
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by amit taneja:
Hi,

its very urgent can any body tell me ..how to deploy the servlet so that every time the computer is on/swithed on , srevlet and obviously ( tomcat container ) starts automatically ..
i m using windows 2k ...
i know i have to make entry in some batch file but what entry ?

pls tell me where to put the servlet so that it runs automatically

thanx and regards,
amit


Hi Amit,

It is interesting to hear your query. What is the use of the servlet deployment after restarting the computer? May be you can make the app/web server is running after the restart and on giving the load-on-startup will deploy the servlets/beans/any services? Is it just to make server auto startup?

Regards,
M.S.Raman
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by amit taneja:
Thanx a ton
can u pls tell me why we use contextlistner in this case ? what is that about ?

Context listeners provide two methods, contextInitialized and contextDestroyed. These methods, as their names imply are tied to the startp and shutdown of your context. They're a better place for initialization code because they only get fired at those times. A servlet container is free to create or destroy servlet instances whenever necessary.
Originally posted by amit taneja:
but how to use contextlistner ?
i mean what entries to be done in that ???

Write a class that that implements ServletContextListener then implement contextInitialized and contextDestroyed. Then, create an entry in your web.xml file for this listener.
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContextListener.html


Originally posted by amit taneja:
can u pls write some thing so that i should copy to that ...

No.
Are you serious?

Originally posted by amit taneja:

actually i don't have much time..

Neither do I

Originally posted by amit taneja:

regards,
amit

And regards to you.
Good luck.
-Ben
[ January 04, 2005: Message edited by: Ben Souther ]
 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanx ben

you answered my question step by step

hahahahah



any way... raman i wanted to make a sheduler which will run automatically even in case machine is restarted.....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic