I have a filter and Login Servlet. How i can check – authorized user or not? and if not authorized – to redirect him to Login Servlet.
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Do this:
When user logs in, set
Userobject for that user in HttpSession. This way,httpRequest.getSession().setAttribute("LOGGED_USER", userObject)Now, every time you hit the filter/security filter. The first thing you do is check for this attribute.
If the attribute is not there, redirect/forward the request to login servlet.
The pseudo code would look like this:
Edit 1: see this http://download.oracle.com/javaee/5/tutorial/doc/bncbx.html