@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
HttpSession session = request.getSession(false);
if (session == null || session.getAttribute("user") == null) {
response.sendRedirect("login"); // No logged-in user found, so redirect to login page.
} else {
chain.doFilter(req, res); // Logged-in user found, so just continue request.
}
}
Monday, January 7, 2019
Session validation filter which logs off the user when session is expired?
Subscribe to:
Post Comments (Atom)
-
@NotNull CharSequence, Collection, Map or Array object cannot be null, however can be empty. @NotEmpty The CharSequence, Collection...
-
We learned about mapping associated entities in hibernate already in previous tutorials such as one-to-one mapping and one-to-many mappi...
-
FetchType (Lazy/Eager) instructs whether the entity to be loaded eagerly or lazy, when there is a call. FetchMode (Select/Join) instructs...
No comments:
Post a Comment