Example usage for javax.servlet ServletConfig getServletContext

List of usage examples for javax.servlet ServletConfig getServletContext

Introduction

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

Prototype

public ServletContext getServletContext();

Source Link

Document

Returns a reference to the ServletContext in which the caller is executing.

Usage

From source file:com.netcracker.financeapp.controller.transaction.TransactionServlet.java

@Override
public void init(ServletConfig config) {
    try {//from   ww  w .  j  a  v  a 2 s .c  om
        super.init(config);
        SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(this, config.getServletContext());
    } catch (ServletException ex) {
        Logger.getLogger(TransactionServlet.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:net.mojodna.sprout.support.SpringHttpServlet.java

/**
 * Initialize the WebApplicationContext for this Action.
 * Invokes onInit after successful initialization of the context.
 * @see #initWebApplicationContext/*from   w  ww.  j  a v a 2s.  c  o  m*/
 * @see #onInit
 */
public void init(final ServletConfig cfg) throws ServletException {
    super.init(cfg);
    if (null != cfg) {
        this.webApplicationContext = initWebApplicationContext(cfg.getServletContext());
        this.messageSourceAccessor = new MessageSourceAccessor(this.webApplicationContext);
        onInit();
    }
}

From source file:mapbuilder.ProxyRedirect.java

/***************************************************************************
 * Initialize variables called when context is initialized
 *
 *///from  ww w .j av  a  2 s .c o m
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    context_ = config.getServletContext();
    log.info("mapbuilder.ProxyRedirect: context initialized to:" + context_.getServletContextName());
}

From source file:org.wso2.carbon.registry.resource.ui.clients.RegistryAdminServiceClient.java

public RegistryAdminServiceClient(String cookie, ServletConfig config, HttpSession session)
        throws RegistryException {

    String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
    ConfigurationContext configContext = (ConfigurationContext) config.getServletContext()
            .getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
    epr = backendServerURL + "RegistryAdminService";

    try {//  w w  w. ja  va  2 s  . co  m
        stub = new RegistryAdminServiceStub(configContext, epr);

        ServiceClient client = stub._getServiceClient();
        Options option = client.getOptions();
        option.setManageSession(true);
        option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);

    } catch (AxisFault axisFault) {
        String msg = "Failed to initiate resource service client. " + axisFault.getMessage();
        log.error(msg, axisFault);
        throw new RegistryException(msg, axisFault);
    }
}

From source file:com.orangeandbronze.jblubble.sample.UploadServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    applicationContext = WebApplicationContextUtils.getWebApplicationContext(config.getServletContext());
    blobstoreService = applicationContext.getBean(BlobstoreService.class);
    blobKeys = new LinkedList<>();
}

From source file:org.geomajas.gwt.server.GeomajasServiceImpl.java

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);

    // register the controller object
    applicationContext = WebApplicationContextUtils.getWebApplicationContext(config.getServletContext());
    if (applicationContext instanceof ConfigurableApplicationContext) {
        ((ConfigurableApplicationContext) applicationContext).addApplicationListener(this);
    }/*ww w .j  a v a  2s  .c om*/
    initDispatcher();
}

From source file:org.kuali.coeus.sys.framework.controller.ConditionalInitDispatcherServlet.java

@Override
public void init(ServletConfig config) throws ServletException {

    if (doInit(config)) {
        super.init(config);
    } else {/*from   ww  w.ja va  2 s.co  m*/
        //logging the same way the super class logs using context logger
        config.getServletContext()
                .log("Not Initialized Spring FrameworkServlet '" + getServletName(config) + "'");
    }
}

From source file:org.wso2.carbon.governance.custom.lifecycles.history.ui.clients.ResourceServiceClient.java

public ResourceServiceClient(String cookie, ServletConfig config, HttpSession session)
        throws RegistryException {

    String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
    ConfigurationContext configContext = (ConfigurationContext) config.getServletContext()
            .getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
    epr = backendServerURL + "ResourceAdminService";

    try {//ww  w.  ja va 2s.co  m
        stub = new ResourceAdminServiceStub(configContext, epr);

        ServiceClient client = stub._getServiceClient();
        Options option = client.getOptions();
        option.setManageSession(true);
        option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);

    } catch (AxisFault axisFault) {
        String msg = "Failed to initiate resource service client. " + axisFault.getMessage();
        log.error(msg, axisFault);
        throw new RegistryException(msg, axisFault);
    }
}

From source file:org.apache.roller.weblogger.ui.rendering.servlets.PreviewThemeImageServlet.java

public void init(ServletConfig config) throws ServletException {

    super.init(config);

    log.info("Initializing PreviewThemeImageServlet");

    this.context = config.getServletContext();
}

From source file:org.infoscoop.web.InitializeServlet.java

/**
 * initialize the Velocity./*from ww  w  .  j  a va2s  .c o m*/
 * @param config :setting for servlet
 * @throws ServletException
 */
protected void initVelocity(ServletConfig config) throws ServletException {
    // maintain the buildVersion in ServletContext.
    String buildVersion = config.getServletContext().getInitParameter("buildTimestamp");
    config.getServletContext().setAttribute("buildTimestamp", buildVersion);

    Properties prop = new Properties();
    prop.put("resource.loader", "class");
    prop.put("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
    prop.put("class.resource.loader.class",
            "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
    prop.put("input.encoding", "UTF-8");
    prop.put("output.encoding", "UTF-8");
    try {
        Velocity.init(prop);
    } catch (Exception e) {
        throw new ServletException(e);
    }
}