1) ActionForms have the method getServlet() which returns an instance of the
ActionServlet.  From this you have access to the ServletContext.

2) The easiest way to access the ServletContext from your bean would be to
pass an instance of the ActionServlet to your bean.  This somewhat goes
against the struts design principles (in the docs anyway) in that they state
that business logic beans should be unaware of the webapp (ie
javax.servlet.xxx) to maintain pluggablility.

IMHO it is ok to create a kind of mediator layer between the action layer
and business logic bean layer that is aware of the webapp and the business
logic layer and can do things like read request params etc.

Hope this helps

Jin
----- Original Message -----
From: "Jürgen Leonhardt" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Monday, November 19, 2001 10:01 AM
Subject: ActionForm & Connection from a Pool


> Hi there,
>
> does anybody know, how to access a database in an ActionForm
> with a Connection from a pool stored in the ServletContext?
>
> Or how can i access the ServletContext in my webapp from any class
> (Not as a Servlet or JSP, lets say a bean) ?
>
> thanks for your help
>
> regards
>
> Jürgen Leonhardt
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>

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

Reply via email to