Class<?> cls = Class.forName(jspClassName, true, classLoader);
HttpJspBase instance = (HttpJspBase) cls.newInstance();
MockServletConfig servletConfig = new MockServletConfig(new MockServletContext());
servletConfig.getServletContext().setAttribute(InstanceManager.class.getName(),
new InstanceManagerImplementation());
JspApplicationContext jspApplicationContext = JspFactory.getDefaultFactory().getJspApplicationContext(
servletConfig.getServletContext());
// Register the ELResolver with JSP
jspApplicationContext.addELResolver(manager.getELResolver());
// Register ELContextListener with JSP
jspApplicationContext.addELContextListener(Reflections
.<ELContextListener> newInstance("org.jboss.weld.el.WeldELContextListener"));
// Push the wrapped expression factory into the servlet context so that
// Tomcat or Jetty can hook it in using a container code
servletConfig.getServletContext().setAttribute(EXPRESSION_FACTORY_NAME,
manager.wrapExpressionFactory(jspApplicationContext.getExpressionFactory()));
instance.init(servletConfig);
JspFactory.setDefaultFactory(new org.apache.jasper.runtime.JspFactoryImpl());
instance._jspInit();
return instance;
}