Hello,
mmm I have a Listener
/**
* @web.listener
* name ="initSession"
* display-name ="InitSession"
* description ="Inicialitza una sessió individual."
*
*/
public class InitSession implements HttpSessionListener {
public void sessionCreated(HttpSessionEvent arg0) {
// TODO Auto-generated method stub
HttpSession session = arg0.getSession();
session.setAttribute("facade", new
com.gmsoft.utils.UtilsSessionFacade());
}
public void sessionDestroyed(HttpSessionEvent arg0) {
// TODO Auto-generated method stub
}
}
I use it for add an attribute for each new created session.
Also, I've implemented a JSP:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"
/>
<title>Insert title here</title>
</head>
<body>
<p>Data:</p>
<%=new java.util.Date(session.getCreationTime()).toString() %>
<% UtilsSessionFacade facade =
(UtilsSessionFacade)session.getAttribute("facade");
if (facade == null) {%>
<%="facade is NULL" %>
<%}else{
ArrayList manufacturers = facade.getManufacturers();
java.util.Iterator it = manufacturers.iterator();
while (it.hasNext()) {%>
<%=((Manufacturer)it.next()).getName() %>
<%}
}
%>
...
and when I want access to my facade session attribute it is NULL.
<web-app id="web-app_1" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<display-name>ecommerce</display-name>
<distributable/>
<listener>
<listener-class>com.gmsoft.InitSession</listener-class>
</listener>
<servlet>
<description><![CDATA[Controlador de tota l'aplicació Web -
MVC]]></description>
<display-name>Controlador</display-name>
<servlet-name>Controller</servlet-name>
<servlet-class>com.gmsoft.ControllerServlet</servlet-class>
</servlet>
</web-app>
Do I do anything wrong?
Thanks in advanced.
--
View this message in context:
http://www.nabble.com/Listener-doesn%27t-listen-tf2095827.html#a5777105
Sent from the Tomcat - User forum at Nabble.com.
---------------------------------------------------------------------
To start a new topic, e-mail: [email protected]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]