Question: In below there is question and answer, What I need is I want comment about the answer( feel free to agree or disagree with answer

In below there is question and answer, What I need is I want comment about the answer( feel free to agree or disagree with answer and explain (in 2 or 3 paragraph) why you agree or disagree)

Question:

when do you implement the listeners/filters... , expalin the advantage and disadvantage of each with example?

Answer:

Filters allow you to preprocess Web application requests and postprocess server responses. Filters really come into their own when you want to apply this kind of preprocessing or postprocessing for a group of servlets. For example, let's say you need to log some information about the requests before they reach the different servlets in your application. Assuming the code that handles the logging is the same for each servlet, you could simply write a single filter that contains this logic and apply it to the different servlets. This is much easier and more efficient than having to copy/paste the same code that handles the logging in the doGet or doPost methods of each of the servlets. Of course, there would be no need for a filter if you just wanted to apply this logic to a single servlet. In that case, you'd just put the code that handles the logging directly in the servlet itself (in the doGet or doPost).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!