Application Scope - Generally, application scope beans are initialized in the
init() method of a startup servlet. However, it is legal for an
Action class to create such beans, if this is appropriate, like this:

    Foo foo = ... create a Foo ...;
    servlet.getServletContext().setAttribute("foo", foo);

---
from
http://jakarta.apache.org/struts/doc-1.0.2/api/org/apache/struts/taglib/bean/package-summary.html#package_description
a really good bit of doc - once you stumble across it.
=================

--- "Farrell, Sarah" <[EMAIL PROTECTED]> wrote:
> Hello,
> 
> I was searching around in the struts-user list archives for the correct
> getServletContext() syntax and found Robert's response to a post:
> http://www.mail-archive.com/struts-user@jakarta.apache.org/msg22768.html
> 
> I am trying to compile an ActionForm and I need to access the *application*
> scoped bean (not a session bean).
> 
> I tried:
> 
> public ActionErrors validate(ActionMapping mapping, HttpServletRequest
> request) 
> {
>       ....
>       Object o =
> request.getSession().getServletContext().getAttribute("attribute_name");
> 
> }
> 
> And it won't compile:
> 
> [javac] C:\cvs
> work\energizer\source\edu\cccs\energizer\SupplementalForm.java:280: cannot
> resolve symbol
>     [javac] symbol  : method getServletContext  ()
>     [javac] location: interface javax.servlet.http.HttpSession
>     [javac]                   Object o =
> request.getSession().getServletContext().getAttribute("attribute_name");
>     [javac]                 
> 
> The difference btw what I'm doing and what Robert had suggested is that I'm
> trying to do it within the ActionForm and not within the Action, but I can't
> figure out why it won't work in the ActionForm.
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 


=====
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Search the archive:-
http://www.mail-archive.com/struts-user%40jakarta.apache.org/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Keith Bacon - Looking for struts work - South-East UK.
phone UK 07960 011275

__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

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

Reply via email to