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]>

Reply via email to