Struts and context

J

Josep

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
 
T

Tim B

Josep said:
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

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");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top