Example usage for javax.servlet ServletConfig getInitParameter

List of usage examples for javax.servlet ServletConfig getInitParameter

Introduction

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

Prototype

public String getInitParameter(String name);

Source Link

Document

Gets the value of the initialization parameter with the given name.

Usage

From source file:org.nanoframework.core.plugins.defaults.plugin.Log4j2Plugin.java

@Override
public void config(ServletConfig config) throws Throwable {
    log4j2 = config.getInitParameter(DEFAULT_LOG4J2_PARAMETER_NAME);
}

From source file:org.examproject.websocket.SpringWebSocketServlet.java

@Override
public void init() throws ServletException {
    try {//from w  w  w  .j  av a  2 s . com
        // trying to load the Spring context file.
        // it's declared in Servlet web.xml.
        ServletConfig sc = getServletConfig();
        String configLocation = sc.getInitParameter("contextConfigLocation");
        context = new FileSystemXmlApplicationContext(
                getServletContext().getRealPath("/") + "/" + configLocation);
        // must call the superclass init method.
        super.init();
    } catch (ServletException se) {
        throw se;
    } catch (Exception e) {
        throw new ServletException(e);
    }
}

From source file:org.pidster.tomcat.websocket.jmx.WebSocketJMXServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    this.path = config.getInitParameter("path");
    super.init(config);
}

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

private boolean doInit(ServletConfig config) {
    final String initConfigPropertyName = config.getInitParameter(INIT_CONFIG_PROPERTY_NAME);
    final String initConfigPropertyValue = config.getInitParameter(INIT_CONFIG_PROPERTY_VALUE);

    boolean init = false;
    if (StringUtils.isNotBlank(initConfigPropertyName)) {
        final String configProperty = getConfigPropertyValue(initConfigPropertyName);
        if (StringUtils.equals(initConfigPropertyValue, configProperty)) {
            init = true;/*from   w ww . j  ava 2s  .com*/
        }
    }
    return init;
}

From source file:org.shredzone.commons.view.servlet.ViewServlet.java

/**
 * Gets the JSP path from the servlet configuration. The default implementation
 * fetches the value from the servlet's "jspPath" init parameter. Extending classes
 * may override this method to fetch the configuration from somewhere else.
 *
 * @param config/*from   w ww .  j a  va2 s  . c  om*/
 *            {@link ServletConfig}
 * @return JSP path, must end with a trailing '/'
 */
protected String getJspPath(ServletConfig config) {
    String jspPath = "/";
    String path = config.getInitParameter("jspPath");
    if (path != null) {
        if (!path.endsWith("/")) {
            path += '/';
        }
        jspPath = path;
    }
    return jspPath;
}

From source file:InitParamServlet.java

public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {

    res.setContentType("text/plain");
    PrintWriter out = res.getWriter();

    String url = getInitParameter("URL");

    ServletConfig config = getServletConfig();
    ServletContext context = getServletContext();
    String uid = config.getInitParameter("UID");
    String pwd = config.getInitParameter("PWD");
    String port = context.getInitParameter("some-port");

    out.println("Values retrieved for the init parameters are: ");
    out.println("URL: " + url);
    out.println("UID: " + uid);
    out.println("PWD: " + pwd);
    out.println("some-port: " + port);
}

From source file:org.onebusaway.presentation.impl.ProxyServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    _target = config.getInitParameter("target");
    if (_target == null)
        throw new ServletException("you did not specify a target parameter");

    _source = config.getInitParameter("source");
}

From source file:org.impalaframework.web.integration.BaseModuleProxyServlet.java

protected RequestModuleMapper newRequestModuleMapper(ServletConfig config) {
    final String requestModuleMapperClass = config
            .getInitParameter(WebConstants.REQUEST_MODULE_MAPPER_CLASS_NAME);
    return ModuleProxyUtils.newRequestModuleMapper(requestModuleMapperClass);
}

From source file:be.fedict.eid.dss.portal.DownloadServlet.java

private String getRequiredInitParameter(ServletConfig config, String paramName) throws ServletException {
    String paramValue = config.getInitParameter(paramName);
    if (null == paramValue) {
        throw new ServletException("missing init-param: " + paramName);
    }//from  ww  w .j a va  2s  .  c  o m
    return paramValue;
}

From source file:org.apache.cxf.fediz.service.idp.MetadataServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    realm = config.getInitParameter(PARAM_REALM);
    if (realm == null || realm.length() == 0) {
        throw new ServletException("Servlet parameter '" + PARAM_REALM + "' not defined");
    }/*w  ww  . j  ava2  s  .co  m*/
}