GeeCON Prague 2014*
The moose likes Servlets and the fly likes how to make servlet able to run as soon as computer started Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "how to make servlet able to run as soon as computer started" Watch "how to make servlet able to run as soon as computer started" New topic
Author

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

amit taneja
Ranch Hand

Joined: Mar 14, 2003
Posts: 810
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


Thanks and Regards, Amit Taneja
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
amit taneja
Ranch Hand

Joined: Mar 14, 2003
Posts: 810
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

Joined: Nov 07, 2001
Posts: 312
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

Joined: Dec 11, 2004
Posts: 13410

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

Joined: Mar 14, 2003
Posts: 810
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.....
 
GeeCON Prague 2014
 
subject: how to make servlet able to run as soon as computer started