Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting application attribute

 
Joseph Sweet
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

I need to set some application attribute in the very beginning whenever tomcat is being restarted.

Where should i put the code to be executed???

somthing like:



any ideas?

Thanks, Joseph
 
Nikhilesh Fonseca
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can put that application scope variable
on init method of oyur controller servlet.That is the sevlet ewhich load on start up as 1.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65221
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prior to the advent of context listeners, a load-on-startup servlet was frequently used to perform application-wide initialization, but a context listener is a much better way to do it now that they are available.

It is guarenteed that all context listeners are executed before any servlets are loaded or executed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic