tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tony L. Mai" <t...@dgateway.com>
Subject Help please. Does Tomcat 5.5 support PhaseListener?
Date Tue, 13 Feb 2007 20:36:13 GMT
Hello all,

I have implemented a ForcedLoginPhaseListener that would intercept every JSF
Request Processing Cycle and check if user has a valid session in the
HttpServletRequest.

Basically the code is as followed:

public class ForcedLoginPhaseListener implements PhaseListener {
	public void afterPhase(PhaseEvent event) {
		FacesContext ctx = event.getFacesContext();
		Object request = ctx.getExternalContext().getRequest();

		HttpSession session = ((HttpServletRequest)
request).getSession(false);
???????	(somehow this session is always be null.)

		....
	}
...
}

I created a HttpSession during login procedure as followed:

Public class LoginController {
	public void login(...) {
		FacesContext ctx = FacesContext.getCurrentInstance();
		HttpServletRequest request = (HttpServletRequest)
ctx.getExternalContext().getRequest();

		HttpSession session = request.getSession(true);
		(session is created here)

		session.setAttribute("UserSession", usrSession);
		...
	}
...
}

Issue: The session obtain during the phase cycle is always null. 

Question: Within the ForcedLoginPhaseListener, I need to get back the
session created during the login procedure. What do I need to do?

Thanks in advance for your help.
-tony


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message