This post walks you through the steps of creating a Hello World example with Spring Boot and JSP.

Spring Boot View Templates Example Series:
- Spring Boot Hello World Example with FreeMarker
- Spring Boot Hello World Example with Thymeleaf
- Spring Boot Hello World Example with JSP

What you'll build

What you'll need

  • Docker CE 18+

Project structure

Project dependencies


Hello Controller

Controller maps HTTP Requests with View.


@RequestMapping maps /hello request to hello() method.

name is a query string parameter of /hello request.

Model object passes value to hello view (hello.jsp).

View Template


Application Configuration



Run

Prepare Dockerfile for Java/Spring Boot application


Start your application and infrastructure via Docker Compose. Make sure your local Docker is running and your bash console is at the springboot-examples project root directory.

docker-compose -f docker-compose-view.yaml up --renew-anon-volumes jsp-helloworld

Source code

https://github.com/hellokoding/springboot-examples/tree/master/view-templates/jsp-helloworld

You may also like the Hello Spring MVC Series:
- Spring MVC 4 Hello World Example with XML Configuration, Maven and JSP
- Spring MVC 4 Hello World Example with XML Configuration, Maven, and Thymeleaf

Serving Web Content with Spring MVC