JasperInitializer implements ServletContainerInitializer { @Override public void onStartup(Set<Class<?>> classes, ServletContext servletContext) throws ServletException { LOGGER.fine("Initializing Jasper integration"); if (JspFactory.getDefaultFactory() == null) { JspFactory.setDefaultFactory(new JspFactoryImpl()); } ServletRegistration.Dynamic registration = servletContext.addServlet("jsp", "org.apache.jasper.servlet.JspServlet"); registration.addMapping("*.jsp"); String classpath = System.getProperty("jdk.module.path", System.getProperty("java.class.path")) + getClassesDirectory(servletContext) + getJarFiles(servletContext); LOGGER.log(FINER, () -> "Jasper classpath is: " + classpath); registration.setInitParameter("classpath", classpath); registration.setInitParameter("compilerSourceVM", "1.8"); registration.setInitParameter("compilerTargetVM", "1.8"); WebApplication webApplication = (WebApplication) servletContext; webApplication.setJspManager(new JasperJspManager()); LOGGER.fine("Initialized Jasper integration"); }  @Override void onStartup(Set<Class<?>> classes, ServletContext servletContext);  }
@Test void testOnStartup() throws Exception { DefaultWebApplication servletContext = new DefaultWebApplication(); servletContext.addResource(new DirectoryResource(new File("src/test/webapp/webapp1"))); JasperInitializer initializer = new JasperInitializer(); initializer.onStartup(new HashSet<>(), servletContext); }