What is the difference between a Servlet and Filter? What do you recommend to use for authorization to pages?
Share
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.
Use a
Filterwhen you want to filter and/or modify requests based on specific conditions. Use aServletwhen you want to control, preprocess and/or postprocess requests.The Java EE tutorial mentions the following about filters:
For authorization, a
Filteris the best suited. Here’s a basic kickoff example of how a filter checks requests for the logged-in user: