Languages
[Edit]
EN

Spring Boot - pre-compile JSP files (Tomcat Server)

8 points
Created by:
Alicia-Lambert
580

In this short article, we would like to show how to pre-compile *.jsp files in Spring Boot application that uses Tomcat Server inside.

JSP pre-compilation in Spring Boot (with Tomcat Server)
Created own JSP pre-compilation controlled in Spring Boot (with Tomcat Server)

Problem: *.jsp files are compiled by Tomcat Server when they are first time used.

Solution: it is necessary to prepare some controller that imports existing *.jsp files without executing them - it will force compilation.

The below code shows how to implement JSP files pre-compiler, which should be run always after the Spring Boot Application is started.

Project structure:

Example implementations

Edit

It is necessary to run pre-compilation by opening preapared link:

  • https://my-domain.com/jsp-compiler to run pre-compiler on deloyment,
  • http://localhost/jsp-compiler to run locally developed project if needed.

JspCompilerController.java file:

jsp_compiler.jsp file:

Alternative titles

  1. Spring Boot - force JSP files pre-compilation (Tomcat Server)
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join