On Mon, 15 Sep 2003, Chang, Henrique wrote:

> Date: Mon, 15 Sep 2003 11:32:38 -0400
> From: "Chang, Henrique" <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: 'Struts Users Mailing List' <[EMAIL PROTECTED]>
> Subject: ActionForm validate() - How to get ServletContext from
>     HttpSessio n in J2EE 1.2
>
> Hi,
>
>       I am using Weblogic 5.1 and if I'm not wrong it is implementing J2EE
> 1.2, in which the HttpSession interface does not specify the
> getServletContext() method.  I need to get to the application context via :
> request -> session -> application.
>
>       My issue is the following :
>
>       In my ActionForm validate() method I need to access an object saved
> to the Application context; however, I can only get access to the
> Application context by means of :
>
>
> request.getSession().getServletContext().getAttribute(myAttributeName);
>
>       Since the ActionForm validate method is inherited and the signature
> is fixed to public ActionErrors validate(ActionMapping mapping,
> javax.servlet.http.HttpServletRequest request), do I have any other
> solutions to this problem ?
>

ActionForm has a getServlet() method, so you can call

  getServlet().getServletContext().getAttribute(myAttributeName);

in a validate() method.

> Thanks,
> Henrique
>

Craig

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

Reply via email to