Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java Open Source > Apache Tomcat
|
Apache Tomcat General discussion of the Apache Tomcat servlet container. For discussions specific to the Professional Apache Tomcat book, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Apache Tomcat section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 16th, 2007, 03:33 AM
Registered User
 
Join Date: Apr 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to sureshrgsl Send a message via Yahoo to sureshrgsl
Default start a context automatically, while tomcat starts

hai.
    i want to start a context automatically in tomcat , while server starts. i am having one context named as helloworld. inside, i am having one helloworld program into the web-inf/classes . it should run automatically while tomcat server starts. please help me out.


 
Old April 16th, 2007, 11:23 PM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,
Can you explain what is your environment i mean is it a pure JSP/Servlet application or are you using any framework?

If you are using Struts framework then use Plugin class of struts, overrided this class in provide the code which you want to execute when the context is deployed.

Regards,
Rakesh
 
Old April 17th, 2007, 01:18 AM
Registered User
 
Join Date: Apr 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to sureshrgsl Send a message via Yahoo to sureshrgsl
Default

hai.
i am not using any framework like struts. purely , jsp/servlet only. that i want to run automatically while server startup. the thing is, In cmd prompt, we are running the tomcat. immediately the simple servlet program also should run automatically after that, from web-inf/classes direc. i am having only one program inside the web-inf/classes direc. not anymore. that too display the helloworld. that all.did u understand. ?? pleaes help me. thanks.


 
Old April 24th, 2007, 01:20 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,

Try setting the load on startup value in the web.xml file to any positive value and use a static block in the servlet and do the necessory steps in that static block.
Please find the information at the following links

http://edocs.bea.com/wls/docs61/weba...l.html#1016508
http://www.caucho.com/resin-3.0/servlet/servlet.xtp
http://wiki.metawerx.net/Wiki.jsp?pa....LoadOnStartup

Regards,
Rakesh
 
Old May 17th, 2007, 06:46 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,
You can use javax.servlet.ServletContextListener interface. You've to implement it and write the code you want to execute in contextInitialized() and contextDestroyed() methods.
You've configure this listener class in your web.xml file using <listener> tag.

Regards,
Rakesh





Similar Threads
Thread Thread Starter Forum Replies Last Post
Tomcat suddenly stops after starts annumol Apache Tomcat 2 February 9th, 2008 01:32 PM
start a context automatically, while tomcat starts sureshrgsl BOOK: Professional Apache Tomcat 0 April 16th, 2007 02:14 AM
start automatically application(s) angelboy .NET Framework 2.0 3 February 4th, 2007 03:33 PM
start automatically application(s) !!!!!!!! angelboy .NET Framework 2.0 1 February 4th, 2007 05:33 AM
start automatically application(s) !!!!!!!! angelboy C# 2005 4 January 31st, 2007 07:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.