Ini contohnya:
public class LoginFilter implements Filter {
public void doFilter(
ServletRequest req,
ServletResponse resp,
FilterChain chain)
throws ServletException, IOException {
LoginSession loginSession = WebUtility.getLogin((HttpServletRequest) req);
if ( loginSession == null) {
req.setAttribute("message","Login Required: Your session is expired or you are not login.");
((HttpServletRequest) req).getRequestDispatcher( "/errorNotLogin.jsp").forward(req, resp);
return;
}
chain.doFilter(req, resp);
}
public void init(FilterConfig config) throws ServletException {
}
public void destroy() {
}
}
No comments:
Post a Comment