Re: Instantiating an Application Scoped Bean

2005-07-27 Thread Tim Funk

Please don't use servlets and the load-on-startup to do this. It is a kludge.

Use a ServletContextListener(). They were intended for just this type of need.

-Tim


Raghupathy,Gurumoorthy wrote:

Define a servlet say "com.guru.servlet.StartUpServlet" 



And in the StartupServlet 



Overide the init() Method 



... init() {
super.init()
getServletContext().setAttribute("MyBean", MyBean);

}



And in WEB.XML 




StartUpServlet

com.guru.servlet.StartUpServlet
1



Regards
Guru


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: 27 July 2005 14:41

To: tomcat-user@jakarta.apache.org
Subject: Instantiating an Application Scoped Bean



Hi,




I need some help on the following scenario:




As soon as I start my tomcat server, I need to populate an
application-scoped bean which will have values from the database.
Thereafter I should be able to access the bean across all JSP pages
using the  tag.




It'll be great if you guys can tell me how to initialize this bean at
server startup. Any specific web.xml entry to be recorded to map to the
servlet which does the DB operation?





Thanks!





Confidentiality Notice


The information contained in this electronic message and any attachments to
this message are intended
for the exclusive use of the addressee(s) and may contain confidential or
privileged information. If
you are not the intended recipient, please notify the sender at Wipro or
[EMAIL PROTECTED] immediately
and destroy all copies of this message and any attachments.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Instantiating an Application Scoped Bean

2005-07-27 Thread Peddireddy Srikanth
One possible solution would be :

U create a servlet which loads on startup. 
While defining servlets in web.xml set the load on startup attribute
for some servlet and that servlet will be loaded/executed 
automatically by container at startup
U can write ur code for loading and populating the bean in that
servlet and u can store that bean in ServletContext object (if iam not
wrong) sothat u can acces it else where


LoadingServlet
LoadingServlet
2


regards
Srikanth
On 7/27/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> 
> Hi,
> 
> 
> 
> I need some help on the following scenario:
> 
> 
> 
> As soon as I start my tomcat server, I need to populate an
> application-scoped bean which will have values from the database.
> Thereafter I should be able to access the bean across all JSP pages
> using the  tag.
> 
> 
> 
> It'll be great if you guys can tell me how to initialize this bean at
> server startup. Any specific web.xml entry to be recorded to map to the
> servlet which does the DB operation?
> 
> 
> 
> Thanks!
> 
> 
> 
> 
> 
> Confidentiality Notice
> 
> The information contained in this electronic message and any attachments to 
> this message are intended
> for the exclusive use of the addressee(s) and may contain confidential or 
> privileged information. If
> you are not the intended recipient, please notify the sender at Wipro or 
> [EMAIL PROTECTED] immediately
> and destroy all copies of this message and any attachments.
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Instantiating an Application Scoped Bean

2005-07-27 Thread Arup Vidyerthy
You need to do something like this:

  
  ApplicationStartup
  StartUp Servlet
  a.startup.ApplicationStartup
  1


   
  ApplicationStartup
  /startup
   

This tells tomcat to run that servlet when Tomcat first intialises the
context. You can put all your initialisation stuff there I guess.

Regards...
Arup Vidyerthy

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: 27 July 2005 14:41
To: tomcat-user@jakarta.apache.org
Subject: Instantiating an Application Scoped Bean


Hi,

 
I need some help on the following scenario:

 
As soon as I start my tomcat server, I need to populate an
application-scoped bean which will have values from the database.
Thereafter I should be able to access the bean across all JSP pages using
the  tag.

 
It'll be great if you guys can tell me how to initialize this bean at server
startup. Any specific web.xml entry to be recorded to map to the servlet
which does the DB operation? 
 
Thanks!





Confidentiality Notice
The information contained in this electronic message and any attachments to
this message are intended for the exclusive use of the addressee(s) and may
contain confidential or privileged information. If you are not the intended
recipient, please notify the sender at Wipro or [EMAIL PROTECTED]
immediately and destroy all copies of this message and any attachments.





___ 
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail 
http://uk.messenger.yahoo.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Instantiating an Application Scoped Bean

2005-07-27 Thread Raghupathy,Gurumoorthy
Define a servlet say "com.guru.servlet.StartUpServlet" 


And in the StartupServlet 


Overide the init() Method 


... init() {
super.init()
getServletContext().setAttribute("MyBean", MyBean);

}



And in WEB.XML 



StartUpServlet

com.guru.servlet.StartUpServlet
1



Regards
Guru


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: 27 July 2005 14:41
To: tomcat-user@jakarta.apache.org
Subject: Instantiating an Application Scoped Bean



Hi,




I need some help on the following scenario:




As soon as I start my tomcat server, I need to populate an
application-scoped bean which will have values from the database.
Thereafter I should be able to access the bean across all JSP pages
using the  tag.




It'll be great if you guys can tell me how to initialize this bean at
server startup. Any specific web.xml entry to be recorded to map to the
servlet which does the DB operation?





Thanks!





Confidentiality Notice


The information contained in this electronic message and any attachments to
this message are intended
for the exclusive use of the addressee(s) and may contain confidential or
privileged information. If
you are not the intended recipient, please notify the sender at Wipro or
[EMAIL PROTECTED] immediately
and destroy all copies of this message and any attachments.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]