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:de.betterform.agent.web.servlet.XFormsRepeater.java

/**
 * Initializes the servlet.//from w  ww.j ava2s . c  om
 *
 * @param config - the ServletConfig object
 * @throws javax.servlet.ServletException
 */
public void init(ServletConfig config) throws ServletException {
    super.init(config);

    useragent = config.getInitParameter("useragent");

    webFactory = new WebFactory();
    webFactory.setServletContext(getServletContext());
    try {
        webFactory.initConfiguration(useragent);
        webFactory.initLogging(getClass());
        String realPath = webFactory.getRealPath(".", getServletContext());
        webFactory.initTransformerService(realPath);
        webFactory.initXFormsSessionCache();

    } catch (XFormsConfigException e) {
        throw new ServletException(e);
    }
}

From source file:org.ppwcode.vernacular.l10n_III.dojo.DojoI18nServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    try {/*w  w  w .java 2 s.c  o m*/
        defaultLocale = Locale.getDefault();
        String loc = config.getInitParameter("defaultLocale");
        if (loc != null) {
            LOG.debug("defaultLocale: " + loc);
            Locale tmpLocale = LocaleHelpers.constructLocaleFromString(loc);
            if (tmpLocale != null) {
                defaultLocale = tmpLocale;
            }
        }
    } catch (Throwable e) {
        e.printStackTrace();
    }
}

From source file:com.lp.webapp.cc.CCOrderResponseServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    authHeader = new WebshopAuthHeader();
    authHeader.setUser(config.getInitParameter(PARAM_USER));
    authHeader.setPassword(config.getInitParameter(PARAM_PASSWORD));
    authHeader.setIsoCountry(config.getInitParameter(PARAM_COUNTRY));
    authHeader.setIsoLanguage(config.getInitParameter(PARAM_LANGUAGE));
    authHeader.setShopName(config.getInitParameter(PARAM_WEBSHOP));

    String xmlMaxSize = config.getInitParameter(CONFIG_MAXSIZE);
    if (null != xmlMaxSize && xmlMaxSize.trim().length() != 0) {
        try {//from   ww  w  . j a v  a 2 s . com
            maxUploadSize = Long.parseLong(xmlMaxSize);
        } catch (NumberFormatException e) {
        }
    }
}

From source file:com.sun.portal.portletcontainer.driver.admin.UploadServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    // TODO Auto-generated method stub
    super.init(config);
    maxUploadSize = config.getInitParameter("MAX_UPLOAD_SIZE") == null ? 10000000
            : Integer.parseInt(config.getInitParameter("MAX_UPLOAD_SIZE"));
    context = config.getServletContext();
}

From source file:org.jfree.eastwood.ChartServlet.java

/**
 * Initialise the servlet.//from  www .  j  a  v a 2 s. c o  m
 *
 * @param config  the config.
 *
 * @throws ServletException
 */
public void init(ServletConfig config) throws ServletException {
    super.init(config);

    String fontSizeParam = config.getInitParameter("fontSize");
    String fontResourceParam = config.getInitParameter("fontResource");
    String fontFileParam = config.getInitParameter("fontFile");
    String fontParam = config.getInitParameter("font");

    float fontSize = 12f;
    if (fontSizeParam != null) {
        fontSize = Integer.parseInt(fontSizeParam);
    }

    if (fontResourceParam != null) {
        ServletContext ctx = config.getServletContext();
        this.font = readFontResource(ctx, fontResourceParam, fontSize);
    } else if (fontFileParam != null) {
        this.font = readFontFile(fontFileParam, fontSize);
    } else if (fontParam != null) {
        this.font = new Font(fontParam, Font.PLAIN, (int) fontSize);
    } else {
        this.font = new Font("Dialog", Font.PLAIN, (int) fontSize);
    }
}

From source file:com.vaadin.grails.terminal.gwt.server.GrailsAwareApplicationServlet.java

/**
 * Called by the servlet container to indicate to a servlet that the servlet
 * is being placed into service./*from  w w w  . j  a  v  a  2 s . co  m*/
 * <p/>
 * This implementation caches the application class name (not the class
 * itself) to use to acquire the Application class from the Grails
 * classloader at runtime.
 *
 * @param servletConfig
 *            the object containing the servlet's configuration and
 *            initialization parameters
 * @throws ServletException
 *             if an exception has occurred that interferes with the
 *             servlet's normal operation.
 */
@SuppressWarnings("unchecked")
@Override
public void init(ServletConfig servletConfig) throws ServletException {
    super.init(servletConfig);

    // Gets the application class name
    final String applicationClassName = servletConfig.getInitParameter("application");
    if (applicationClassName == null) {
        throw new ServletException(
                "The 'application' servlet init parameter was not specified.  This parameter "
                        + "must be specified with a value of a fully qualified class name of a class that extends "
                        + "com.vaadin.Application.");
    }

    this.applicationClassName = applicationClassName;
    // make sure it exists at startup:
    try {
        getApplicationClass();
    } catch (ClassNotFoundException e) {
        throw new ServletException("Failed to load application class: " + this.applicationClassName, e);
    }
}

From source file:org.xwiki.test.sso.LDAPStatus.java

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

    if (config.getInitParameter("xwiki.cfg") != null) {
        xwikicfgPath = config.getInitParameter("xwiki.cfg");
    }//from w w  w  .j  a  va2s .  c o  m

    try {
        conf = new PropertiesConfiguration(xwikicfgPath);
    } catch (ConfigurationException ex) {
        log.log(Level.SEVERE, null, ex);
        throw new ServletException(ex);
    }

}

From source file:de.micromata.genome.gwiki.web.GWikiServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    servletPath = config.getInitParameter("servletPath");
    contextPath = config.getInitParameter("contextPath");
    if (contextPath == null) {
        contextPath = config.getServletContext().getContextPath();
    }//from   ww  w .j av a 2  s . c  om
    if (daoContext == null) {
        String className = config.getInitParameter(
                "de.micromata.genome.gwiki.model.config.GWikiBootstrapConfigLoader.className");
        if (StringUtils.isBlank(className) == true) {
            throw new ServletException(
                    "de.micromata.genome.gwiki.model.config.GWikiBootstrapConfigLoader.className is not set in ServletConfig for GWikiServlet");
        }
        GWikiBootstrapConfigLoader loader = ClassUtils.createDefaultInstance(className,
                GWikiBootstrapConfigLoader.class);
        daoContext = loader.loadConfig(config);
    }
}

From source file:org.opensubsystems.core.util.servlet.WebUtils.java

/**
 * Create debug string containing all parameter names and their values from
 * the config.//w w w. j a  v  a  2  s  .  c o  m
 *
 * @param  scConfig - config to print out
 * @return String - debug string containing all parameter names and their
 *                  values from the config
 */
public static String debug(ServletConfig scConfig) {
    Enumeration enumNames;
    String strParam;
    StringBuilder sbfReturn = new StringBuilder();

    sbfReturn.append("ServletConfig=[ServletName=");
    sbfReturn.append(scConfig.getServletName());
    sbfReturn.append(";");
    for (enumNames = scConfig.getInitParameterNames(); enumNames.hasMoreElements();) {
        strParam = (String) enumNames.nextElement();
        sbfReturn.append("Param=");
        sbfReturn.append(strParam);
        sbfReturn.append(" value=");
        sbfReturn.append(scConfig.getInitParameter(strParam));
        if (enumNames.hasMoreElements()) {
            sbfReturn.append(";");
        }
    }
    sbfReturn.append("]");

    return sbfReturn.toString();
}