Example usage for javax.servlet GenericServlet getServletContext

List of usage examples for javax.servlet GenericServlet getServletContext

Introduction

In this page you can find the example usage for javax.servlet GenericServlet getServletContext.

Prototype

public ServletContext getServletContext() 

Source Link

Document

Returns a reference to the ServletContext in which this servlet is running.

Usage

From source file:org.agnitas.webservice.WebServiceBase.java

protected Connection getConnection(MessageContext msct) {
    Connection dbConn = null;/*from  w ww .j a  v  a 2s . c o  m*/

    GenericServlet aServlet = (GenericServlet) msct.getProperty("transport.http.servlet");

    if (agnDBPool == null) {
        agnDBPool = AgnUtils.retrieveDataSource(aServlet.getServletContext());
    }

    try {
        dbConn = agnDBPool.getConnection();
    } catch (Exception e) {
        dbConn = null;
    }
    return dbConn;
}

From source file:org.nuxeo.ecm.webengine.WebEngine.java

/**
 * JSP taglib support/*from  w  w  w  .  j  a  va  2s  .  c  o m*/
 */
public void loadJspTaglib(GenericServlet servlet) {
    if (rendering instanceof FreemarkerEngine) {
        FreemarkerEngine fm = (FreemarkerEngine) rendering;
        ServletContextHashModel servletContextModel = new ServletContextHashModel(servlet,
                fm.getObjectWrapper());
        fm.setSharedVariable("Application", servletContextModel);
        fm.setSharedVariable("__FreeMarkerServlet.Application__", servletContextModel);
        fm.setSharedVariable("Application", servletContextModel);
        fm.setSharedVariable("__FreeMarkerServlet.Application__", servletContextModel);
        fm.setSharedVariable("JspTaglibs", new TaglibFactory(servlet.getServletContext()));
    }
}