javax.servlet.jsp.JspFactory Java Examples

The following examples show how to use javax.servlet.jsp.JspFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JSPEngineWrapper.java    From ontopia with Apache License 2.0 7 votes vote down vote up
private static WrapperIF getWrapper() {
  if (wrapper != null)
    return wrapper;

  if (JspFactory.getDefaultFactory() == null)
    // ontojsp can't set the default factory, since ontojsp needs to
    // be able to run inside app servers, which will set the default.
    // in the test suite there will therefore be no default factory.
    return new JSP12Wrapper(); 

  JspEngineInfo engine = JspFactory.getDefaultFactory().getEngineInfo();
  String version = engine.getSpecificationVersion();
  switch (version) {
    case "2.0": return new JSP20Wrapper();
    case "1.2": return new JSP12Wrapper();
    default: return new JSP11Wrapper();
  }
}
 
Example #2
Source File: TilesConfigurer.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public AttributeEvaluator createEvaluator() {
	ELAttributeEvaluator evaluator = new ELAttributeEvaluator();
	evaluator.setExpressionFactory(
			JspFactory.getDefaultFactory().getJspApplicationContext(servletContext).getExpressionFactory());
	evaluator.setResolver(new CompositeELResolverImpl());
	return evaluator;
}
 
Example #3
Source File: OpenEJBLifecycle.java    From tomee with Apache License 2.0 5 votes vote down vote up
/**
 * On Tomcat we need to sometimes force a class load to get our hands on the JspFactory
 */
private static void setJspELFactory(ServletContext startupObject, ELResolver resolver)
{
    JspFactory factory = JspFactory.getDefaultFactory();
    if (factory == null)
    {
        try
        {
            try {
                Class.forName("org.apache.jasper.servlet.JasperInitializer");
            } catch (final Throwable th) {
                Class.forName("org.apache.jasper.compiler.JspRuntimeContext");
            }
            factory = JspFactory.getDefaultFactory();
        }
        catch (Exception e)
        {
            // ignore
        }

    }

    if (factory != null)
    {
        JspApplicationContext applicationCtx = factory.getJspApplicationContext(startupObject);
        applicationCtx.addELResolver(resolver);
    }
    else
    {
        logger.debug("Default JSPFactroy instance has not found. Skipping OWB JSP handling");
    }
}
 
Example #4
Source File: ViewerPlugin.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void setupJspFactory() {

		try {
			if (JspFactory.getDefaultFactory() == null) {
				// enforce setting the jspfactory instance as we know it here
				Class clz = Class.forName("org.apache.jasper.runtime.JspFactoryImpl"); //$NON-NLS-1$
				if (clz != null) {
					JspFactory.setDefaultFactory((JspFactory) clz.newInstance());
				}
			}
		} catch (Exception ex) {

		}
	}
 
Example #5
Source File: TestPageContextImpl.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    PageContext pageContext = JspFactory.getDefaultFactory().getPageContext(
            this, req, resp, null, false, JspWriter.DEFAULT_BUFFER, true);
    JspWriter out = pageContext.getOut();
    if (Constants.DEFAULT_BUFFER_SIZE == out.getBufferSize()) {
        resp.getWriter().println("OK");
    } else {
        resp.getWriter().println("FAIL");
    }
}
 
Example #6
Source File: Validator.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
ValidateVisitor(Compiler compiler) {
    this.pageInfo = compiler.getPageInfo();
    this.err = compiler.getErrorDispatcher();
    this.loader = compiler.getCompilationContext().getClassLoader();
    // Get the cached EL expression factory for this context
    expressionFactory =
            JspFactory.getDefaultFactory().getJspApplicationContext(
            compiler.getCompilationContext().getServletContext()).
            getExpressionFactory();
}
 
Example #7
Source File: TilesConfigurer.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
public AttributeEvaluator createEvaluator() {
	ELAttributeEvaluator evaluator = new ELAttributeEvaluator();
	evaluator.setExpressionFactory(
			JspFactory.getDefaultFactory().getJspApplicationContext(servletContext).getExpressionFactory());
	evaluator.setResolver(new CompositeELResolverImpl());
	return evaluator;
}
 
Example #8
Source File: JspContextWrapper.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public ELContext getELContext() {
    if (elContext == null) {
        elContext = new ELContextWrapper(rootJspCtxt.getELContext(), jspTag, this);
        JspFactory factory = JspFactory.getDefaultFactory();
        JspApplicationContext jspAppCtxt = factory.getJspApplicationContext(servletContext);
        if (jspAppCtxt instanceof JspApplicationContextImpl) {
            ((JspApplicationContextImpl) jspAppCtxt).fireListeners(elContext);
        }
    }
    return elContext;
}
 
Example #9
Source File: TestPageContextImpl.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    PageContext pageContext = JspFactory.getDefaultFactory().getPageContext(
            this, req, resp, null, false, JspWriter.DEFAULT_BUFFER, true);
    JspWriter out = pageContext.getOut();
    if (Constants.DEFAULT_BUFFER_SIZE == out.getBufferSize()) {
        resp.getWriter().println("OK");
    } else {
        resp.getWriter().println("FAIL");
    }
}
 
Example #10
Source File: Validator.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
ValidateVisitor(Compiler compiler) {
    this.pageInfo = compiler.getPageInfo();
    this.err = compiler.getErrorDispatcher();
    this.loader = compiler.getCompilationContext().getClassLoader();
    // Get the cached EL expression factory for this context
    expressionFactory =
            JspFactory.getDefaultFactory().getJspApplicationContext(
            compiler.getCompilationContext().getServletContext()).
            getExpressionFactory();
}
 
Example #11
Source File: JasperInitializer.java    From piranha with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 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");
}
 
Example #12
Source File: SystemInit.java    From bbs with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void setServletContext(ServletContext context) {
//	context.getSessionCookieConfig().setHttpOnly(true);
    
	//JSTL EL表达式XSS过滤
	JspFactory.getDefaultFactory()
       .getJspApplicationContext(context)
       .addELResolver(new EscapeXmlELResolver());
}
 
Example #13
Source File: TilesConfigurer.java    From java-technology-stack with MIT License 5 votes vote down vote up
public AttributeEvaluator createEvaluator() {
	ELAttributeEvaluator evaluator = new ELAttributeEvaluator();
	evaluator.setExpressionFactory(
			JspFactory.getDefaultFactory().getJspApplicationContext(servletContext).getExpressionFactory());
	evaluator.setResolver(new CompositeELResolverImpl());
	return evaluator;
}
 
Example #14
Source File: TilesConfigurer.java    From spring-analysis-note with MIT License 5 votes vote down vote up
public AttributeEvaluator createEvaluator() {
	ELAttributeEvaluator evaluator = new ELAttributeEvaluator();
	evaluator.setExpressionFactory(
			JspFactory.getDefaultFactory().getJspApplicationContext(servletContext).getExpressionFactory());
	evaluator.setResolver(new CompositeELResolverImpl());
	return evaluator;
}
 
Example #15
Source File: TestPageContextImpl.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    PageContext pageContext = JspFactory.getDefaultFactory().getPageContext(
            this, req, resp, null, false, JspWriter.DEFAULT_BUFFER, true);
    JspWriter out = pageContext.getOut();
    if (Constants.DEFAULT_BUFFER_SIZE == out.getBufferSize()) {
        resp.getWriter().println("OK");
    } else {
        resp.getWriter().println("FAIL");
    }
}
 
Example #16
Source File: Validator.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
ValidateVisitor(Compiler compiler) {
    this.pageInfo = compiler.getPageInfo();
    this.err = compiler.getErrorDispatcher();
    this.loader = compiler.getCompilationContext().getClassLoader();
    // Get the cached EL expression factory for this context
    expressionFactory =
            JspFactory.getDefaultFactory().getJspApplicationContext(
            compiler.getCompilationContext().getServletContext()).
            getExpressionFactory();
}
 
Example #17
Source File: HomeLogic.java    From JspMyAdmin2 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 
 * @param bean
 * @throws SQLException
 */
public void fillBean(Bean bean) throws SQLException {
	HomeBean homeBean = null;
	ApiConnection apiConnection = null;
	DatabaseMetaData databaseMetaData = null;
	PreparedStatement statement = null;
	ResultSet resultSet = null;
	ServletContext context = null;
	try {
		homeBean = (HomeBean) bean;
		apiConnection = getConnection();
		databaseMetaData = apiConnection.getDatabaseMetaData();
		homeBean.setDb_server_user(databaseMetaData.getUserName());

		statement = apiConnection.getStmtSelect("SHOW VARIABLES WHERE VARIABLE_NAME = ?");
		statement.setString(1, Constants.COLLATION_SERVER);
		resultSet = statement.executeQuery();
		while (resultSet.next()) {
			homeBean.setCollation(resultSet.getString(2));
		}
		resultSet.close();
		resultSet = null;
		statement.close();
		statement = null;

		statement = apiConnection.getStmtSelect("SHOW VARIABLES WHERE VARIABLE_NAME = ?");
		statement.setString(1, Constants.HOSTNAME);
		resultSet = statement.executeQuery();
		while (resultSet.next()) {
			homeBean.setDb_server_name(resultSet.getString(2));
		}
		resultSet.close();
		resultSet = null;
		statement.close();
		statement = null;

		statement = apiConnection.getStmtSelect("SHOW VARIABLES WHERE VARIABLE_NAME = ?");
		statement.setString(1, Constants.VERSION_COMMENT);
		resultSet = statement.executeQuery();
		while (resultSet.next()) {
			homeBean.setDb_server_type(resultSet.getString(2));
		}
		resultSet.close();
		resultSet = null;
		statement.close();
		statement = null;

		statement = apiConnection.getStmtSelect("SHOW VARIABLES WHERE VARIABLE_NAME = ?");
		statement.setString(1, Constants.VERSION);
		resultSet = statement.executeQuery();
		while (resultSet.next()) {
			homeBean.setDb_server_version(resultSet.getString(2));
		}
		resultSet.close();
		resultSet = null;
		statement.close();
		statement = null;

		statement = apiConnection.getStmtSelect("SHOW VARIABLES WHERE VARIABLE_NAME = ?");
		statement.setString(1, Constants.PROTOCOL_VERSION);
		resultSet = statement.executeQuery();
		while (resultSet.next()) {
			homeBean.setDb_server_protocol(resultSet.getString(2));
		}
		resultSet.close();
		resultSet = null;
		statement.close();
		statement = null;

		statement = apiConnection.getStmtSelect("SHOW VARIABLES WHERE VARIABLE_NAME = ?");
		statement.setString(1, Constants.CHARACTER_SET_SERVER);
		resultSet = statement.executeQuery();
		while (resultSet.next()) {
			homeBean.setDb_server_charset(resultSet.getString(2));
		}
		resultSet.close();
		resultSet = null;
		statement.close();
		statement = null;

		context = DefaultServlet.getContext();
		homeBean.setWeb_server_name(context.getServerInfo());
		homeBean.setJdbc_version(databaseMetaData.getDriverVersion());
		homeBean.setJava_version(System.getProperty("java.version"));
		homeBean.setServelt_version(
				context.getMajorVersion() + Constants.SYMBOL_DOT + context.getMinorVersion());
		homeBean.setJsp_version(JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion());
	} finally {
		close(resultSet);
		close(statement);
		close(apiConnection);
	}
}
 
Example #18
Source File: PageContextImpl.java    From packagedrone with Eclipse Public License 1.0 3 votes vote down vote up
PageContextImpl(JspFactory factory) {
       this.factory = factory;
this.outs = new BodyContentImpl[0];
this.attributes = new HashMap<String, Object>(16);
this.depth = -1;
   }