Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2006

Tip: Looking for answers? Try searching our database.

Struts and context

Thread view: 
Josep - 27 May 2006 14:30 GMT
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");


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.