Spring Web MVC – Configure JSP Support

In this tutorial, you will learn how to configure the Spring Boot Web MVC application to support JSP(Java Server pages) and JSTL(JSP Standard Tag Library).

Video Tutorial

Maven Dependencies

To configure your Spring Boot application to support Spring MVC, JSP and JSTL add the following maven dependencies to the pom.xml file.

Spring Web

The following dependency will add support to build Spring Web MVC applications as well as RESTful Web Services with Spring Framework.



The following Maven dependency will add support for JSP. Notice the provided scope. This scope is required.

<!-- https://mvnrepository.com/artifact/org.apache.tomcat.embed/tomcat-embed-jasper -->


The following Maven dependency will add support for JSTL. The provided scope is optional.

<!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->

JSP Folder

Now that we have added the required maven dependencies, your application can support JSP. JSP pages are usually placed in the following directory /src/main/webapp/WEB-INF/jspIf your Spring Boot application does not have this directory, then you should create it.

Application Properties File

Now that you have created a folder for your JSP pages, we need to tell Spring Framework about its location. We also need to configure suffix that needs to be used for the View pages.

Add the following two properties to the application.properties file of your Spring Boot application.


And this is it!

Your application is now configured to support JSP and JSTL.

JSP Page

You can now create a new JSP page and test your application. Create and place the following JSP page into /src/main/webapp/WEB-INF/jsp folder.

<%@ page language="java" contentType="text/html; charset=UTF-8"
<!DOCTYPE html>
<meta charset="UTF-8">
<title>Insert title here</title>
 <%="This is my JSP page"%>

Controller Class

You can use the following Controller class to handle HTTP requests and make it display a JSP page.

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

public class HomeController {

    public String homePage() {
        return "home";


The homePage() method will be triggered when we access the root resource of our website http://localhost:8080/. This is because we use the forward-slash / in the RequestMapping() annotation.

When this method completes, it will return the name of the View that needs to be displayed to a user. The name of the view is “home”. When Spring Framework adds Prefix and Suffix to this View, it will be able to locate the home.jsp page that is placed in the /src/main/webapp/WEB-INF/jsp/ folder.

I hope this tutorial was helpful for you. If you are interested in learning more about Spring Web MVC then check other tutorials in the Spring Web MVC category.

Leave a Reply

Your email address will not be published. Required fields are marked *