Hi,
I have a doubt with struts.
How do I put some value in a context of application from an action?
I have a web application with a "listener" that puts "ds" key in the
context of application with de value of a Datasource retrieved with JNDI
. THE pool was created with tomcat.
And then I want to call DAO's from my Action, but my DAO's requires that
I pass the Datasource.
How do I for put something in the context of application and where?
The "listener" puts the value when the context of application is
created, but then, how do I retrieve this value inside an action?
Thanks a lot.
Josep
Tim B - 27 May 2006 21:49 GMT
> Hi,
>
[quoted text clipped - 17 lines]
>
> Josep
You could use something like this to retrieve the value in an action:
String myValue= (String )
request.getSession().getServletContext().getAttribute("mykey");
To set it:
request.getSession().getServletContext().setAttribute("mykey",
"differentValue");