You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by John Jones <jo...@kingchompy.com> on 2002/03/23 16:59:53 UTC

Application scope beans

Does anyone out there know how to access objects in application scope from a servlet? We want to have a startup servlet that puts a bunch of beans in application scope on application server startup.

RE: Application scope beans

Posted by "Juan Alvarado (Struts List)" <ju...@manduca.com>.
John:

The following snipet of code should handle what you need:

Object someObject =
(Object)servlet.getServletContext().getAttribute("nameOfObjectHandleInApplic
ation");

The reference to Object above would of course be replaced with the class
name of the object you are trying to access.
Also, the code above assumes you are calling the servlet from within an
Action.

Please let me know if this works for you.

**********************************************
Juan Alvarado
Internet Developer -- Manduca Management
(786)552-0504
jalvarado@manduca.com
AOL Instant Messenger: juan2000@aol.com

-----Original Message-----
From: John Jones [mailto:john@kingchompy.com]
Sent: Saturday, March 23, 2002 11:00 AM
To: Struts Users Mailing List
Subject: Application scope beans


Does anyone out there know how to access objects in application scope from a
servlet? We want to have a startup servlet that puts a bunch of beans in
application scope on application server startup.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>