Built-in Tomcat JSPServlet Options for SpringBoot

What is the preferred way to set configuration parameters for JSPServlet like checkInterval, keepgenerated, modifyTestInterval etc.? The reason I'm trying to change it is due to some weird JSP compilation issues. We use executable military packaging and set the server.tomcat.basedir property to point to a locally accessible folder. The generated jsp java source file and class files show the change date as January 14, 1970. In Windows Explorer, the modification simply appears as empty. In linux, we touched all files. But as soon as the jsp file is accessed again, the modification date goes back to 1970. We doubt that this leads to the fact that jsp files are compiled every time it is accessed and thus slow down. However, recompiling seems to beonly happens on a Linux environment. Has anyone experienced this problem? Our environment: Spring Boot 1.2.2.BUILD-SNAPSHOT, Tomcat 8, JDK 1.8_025.

0
source share
2 answers

You can use the EmbeddedServletContainerCustomizer @BeanJSP to find the servlet and configure its init parameters. For example, in your main class @Configuration:

@Bean
public EmbeddedServletContainerCustomizer customizer() {
    return new EmbeddedServletContainerCustomizer() {

        @Override
        public void customize(ConfigurableEmbeddedServletContainer container) {
            if (container instanceof TomcatEmbeddedServletContainerFactory) {
                customizeTomcat((TomcatEmbeddedServletContainerFactory) container);
            }
        }

        private void customizeTomcat(TomcatEmbeddedServletContainerFactory tomcat) {
            tomcat.addContextCustomizers(new TomcatContextCustomizer() {

                @Override
                public void customize(Context context) {
                    Wrapper jsp = (Wrapper) context.findChild("jsp");
                    jsp.addInitParameter("modificationTestInterval", "10");
                }
            });
        }
    };
}
+1
source

Or you can simply add parameters to the application.properties file, as described here: https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html Look for:
  server.jsp -servlet.init-parameters. * = # Initialization parameters used to configure the JSP servlet

For example:

server.jsp-servlet.init-parameters.modificationTestInterval=10
0
source

Source: https://habr.com/ru/post/1625921/


All Articles