I wrote a filter for my jsp pages , I am success ful in redirecting the jsp pages if entered manually to login.jsp.
I want to validate the filter , if some user logs in he shud be able to continue the session (I am not able to do tht)
I think I have to validate the filter (if the user cud login , he can continue or else the page is redirected to login.jsp----- how do I do this).

Can anyone please help me how do I validate the filter.(I need to enter the filter only when there is no login session else I have to continue to my jsp page )
I have few tabs after I login (assume user tab--- user.jsp ) , user shud e able to enter the user.jsp page after he logs in
Here is my LoginBean


mport java.util.Map;

import javax.faces.context.FacesContext;

public class LoginBean extends AbstractBean {

private String loginId;
private String password;

private LoginService loginService;

private LoginValidator loginValidator = new LoginValidator();

private TenantProfileService tenantProfileService;

public String getLoginId() {
return loginId;
}

public void setLoginId(String _loginId) {
loginId = _loginId;
}

public String getPassword() {
return password;
}

public void setPassword(String _password) {
password = _password;
}

public LoginService getLoginService() {
return loginService;
}

public void setLoginService(LoginService loginService) {
this.loginService = loginService;
}

public String login() {

* String authenticationStatus = GenesisConstants.RESULT_FAIL;*

* appLogger.enterMethod(this, "login", loginId);*
* if (loginValidator.validateData(this)) {*
* try {*
* long profileId = loginService.authenticateUser(loginId,*
* password);*
* TenantProfileData tenantProfileData = retrieveTenantProfile(profileId);*

* if (tenantProfileData == null || !tenantProfileData.getStatus().equalsIgnoreCase(*
* GenesisConstants.TENANT_STATUS_ACTIVE))*
* throw new LoginException(*
* "Tenant profile Not Active for the user.");*
* authenticationStatus = GenesisConstants.RESULT_SUCCESS;*
* } catch (LoginException le) {*
* appLogger.error("Error in User Authentication", le.getMessage());*
loginValidator.addErrorMessage(null, le.getMessage());
* authenticationStatus = GenesisConstants.RESULT_FAIL;*
* }*
* }*

appLogger.exitMethod(this, "login", loginId);
return authenticationStatus;
}

public TenantProfileData retrieveTenantProfile(long profileId) {
appLogger.enterMethod(this, "viewTenant");
FacesContext facesContext = FacesContext.getCurrentInstance();
Map<String, Object> sessionMap = facesContext.getExternalContext()
.getSessionMap();
appLogger.debug("profileId==", profileId + "");

TenantProfileData tenantProfileData = new TenantProfileData();
try {

appLogger.debug("invoking TenantProfileService.getTenantById");
tenantProfileData = tenantProfileService.getTenantById(profileId);
appLogger
.debug("successfully completed TenantProfileService.getTenantById");
} catch (TenantProfileServiceException te) {
appLogger.debug("exception in TenantProfileService.getTenantById");
throw new DataException(te.getMessage());
}

sessionMap.put("tenantProfileData", tenantProfileData);
appLogger.exitMethod(this, "viewTenant");

return tenantProfileData;
}

public TenantProfileService getTenantProfileService() {
return tenantProfileService;
}

public void setTenantProfileService(
TenantProfileService tenantProfileService) {
this.tenantProfileService = tenantProfileService;
}

}

and this is the filter I have written

mport java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class FacesRedirectFilter implements Filter {

public void doFilter(ServletRequest req,ServletResponse res,FilterChain chain)
throws ServletException, IOException
{
HttpServletRequest request = (HttpServletRequest)req;
HttpServletResponse response = (HttpServletResponse)res;
//String uri = request.getRequestURI();
String relativePath = request.getServletPath();

if ((relativePath.indexOf("/pages/") >= 0) && relativePath.endsWith(".jsf")) {
//int length = uri.length();
//String newAddress = uri.substring(0, length-3) + EXTENSION;

//response.sendRedirect("login.jsf");
RequestDispatcher rd = request.getRequestDispatcher("login.jsf");
rd.forward(req, res);

}

chain.doFilter(request, response);
}
public void destroy() {
// TODO Auto-generated method stub

}
public void init(FilterConfig filterConfig) throws ServletException {
// TODO Auto-generated method stub

}
}

Please provide the code for the validation

thanks