Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Apache Tomcat »

Help please. Does Tomcat 5.5 support PhaseListener?

Tony L. Mai

2007-02-13


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@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.