Book Image

Spring MVC Beginner's Guide

By : Amuthan Ganeshan
Book Image

Spring MVC Beginner's Guide

By: Amuthan Ganeshan

Overview of this book

Table of Contents (19 chapters)
Spring MVC Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – configuring an interceptor


Every web request takes a certain amount of time to get processed in the server. In order to find out how much time it takes to process a web request, we need to calculate the time difference between the start time and end time of the web request process. We can achieve this using the interceptor concept. Let's configure our own interceptor in our project to log the execution time of each web request by performing the following steps:

  1. Open pom.xml—you can find pom.xml under the root directory of the project itself.

  2. You will be able to see some tabs at the bottom of the pom.xml file; select the Dependencies tab and click on the Add button of the Dependencies section.

  3. A Select Dependency window will appear; enter Group Id as log4j, enter Artifact Id as log4j, enter Version as 1.2.12, select Scope as compile, and click on the OK button to save pom.xml.

  4. Create a class named PerformanceMonitorInterceptor under the com.packt.webstore.interceptor package...