Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java Open Source > Apache Tomcat
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 16th, 2007, 03:33 AM
Registered User
 
Join Date: Apr 2007
Location: bangalore, karnataka, India.
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.


Reply With Quote
  #2 (permalink)  
Old April 16th, 2007, 11:23 PM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hyderabad, A.P., India.
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
Reply With Quote
  #3 (permalink)  
Old April 17th, 2007, 01:18 AM
Registered User
 
Join Date: Apr 2007
Location: bangalore, karnataka, India.
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.


Reply With Quote
  #4 (permalink)  
Old April 24th, 2007, 01:20 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hyderabad, A.P., India.
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
Reply With Quote
  #5 (permalink)  
Old May 17th, 2007, 06:46 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hyderabad, A.P., India.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 11:48 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.