/**
* Initialize Jasper.
*
* @param classes the classes.
* @param servletContext the Servlet context.
* @throws ServletException when a Servlet error occurs.
*/
@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 Servlet", "org.apache.jasper.servlet.JspServlet");
registration.addMapping("*.jsp");
String classpath = System.getProperty("java.class.path")
+ getClassesDirectory(servletContext)
+ getJarFiles(servletContext);
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.log(Level.FINER, "Jasper classpath is: {0}", 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");
}