• Post Reply Bookmark Topic Watch Topic
  • New Topic

Run servlet program when start apache-tomcat

 
R Sugan
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I tried to get output of my Servlet program when start Apache-tomcat.How to proceed this process.please assist to me.


Thanks
 
Surya Kant
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do it by specifying
<load-on-startup> in servlet definition.
You can find this in web.xml
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't get response without firing a request.

Besides, this is a design smell. Have you considered ServletContextListener?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65529
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since the purpose of a servlet is to render a response to a request, and there's no request to respond to on startup, it makes no sense to do this with a servlet. Investigate the use of listeners as Bauke recommended.
 
R Sugan
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for reply.I got the output.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!