I need do something special to specific Servlet class object by :
if (currentServlet instanceof SpecificServlet) {
// do something special...
}
But I can not find a method in FIlter to get the currentServlet.
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.
There is no such thing as current servlet in a filter. In fact sometimes the filter itself handles the whole request and no servlet is needed.
What do you want to achieve? Note that if you want to run some method on a servlet you might get unexpected results as servlets are shared between multiple concurrent requests. You’ll probably need some sort of indirection, like storing a request or session attribute in filter and retrieving it in servlet.
See also