struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Raman" <>
Subject DataSource help
Date Fri, 13 Feb 2004 12:05:48 GMT
Hi All,

I have a problem regarding the DB connection. In my application i want to log the session
time for each session. For that I am using the Session Listner in web.xml somthing like: 

My problem is:

In my struts-config.xml file I have <data-source><set-property> defined for my
what I am thinking is to call Insert query in 
public void sessionCreated(HttpSessionEvent event) { } 

and update query public void sessionDestroyed(HttpSessionEvent event) {} function

But my problem is how to get and pass the DataSource that refers to my DB defined in <datasource>
tag of struts-conf file to my DAO file.

   String name = event.getName();
   HttpSession session = event.getSession();
   ServletContext sc = session.getServletContext();   
   DataSource dataSource =(DataSource)sc.getAttribute(Action.DATA_SOURCE_KEY);   
   UpdateSessionListenerDAO dao= new  UpdateSessionListenerDAO(dataSource);
   }catch(Exception e){
    System.out.println("ERROR " + e.getMessage());

But this is not working I was not able to figure out the reason.

Pls help.. 

-- Raman
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message