List of usage examples for javax.servlet ServletConfig getInitParameter
public String getInitParameter(String name);
From source file:nl.mineleni.cbsviewer.servlet.ReverseProxyServlet.java
/** * Initialize variables called when context is initialized. Leest de waarden * van {@link #ALLOWED_HOSTS} (verplichte optie) en {@link #FORCE_XML_MIME} * uit de configuratie./*from ww w . j av a 2s . c o m*/ * * @param config * the <code>ServletConfig</code> object that contains * configutation information for this servlet * @throws ServletException * if an exception occurs that interrupts the servlet's normal * operation */ @Override public void init(final ServletConfig config) throws ServletException { super.init(config); final String forceXML = config.getInitParameter(FORCE_XML_MIME); this.forceXmlResponse = (null != forceXML ? Boolean.parseBoolean(forceXML) : false); String csvHostnames = config.getInitParameter(ALLOWED_HOSTS); if (csvHostnames == null) { LOGGER.error(ERR_MSG_MISSING_CONFIG); throw new ServletException(ERR_MSG_MISSING_CONFIG); } // clean-up whitespace and case csvHostnames = csvHostnames.replaceAll("\\s", "").toLowerCase(); final String[] names = csvHostnames.split(";"); for (final String name : names) { this.allowedHosts.add(name); if (LOGGER.isDebugEnabled()) { LOGGER.debug("toevoegen aan allowed host namen: " + name); } } // http client set up this.client = HttpClients.createSystem(); this.requestConfig = RequestConfig.custom().setCookieSpec(CookieSpecs.IGNORE_COOKIES).build(); if ((null != this.getProxyHost()) && (this.getProxyPort() > 0)) { final HttpHost proxy = new HttpHost(this.getProxyHost(), this.getProxyPort(), "http"); this.requestConfig = RequestConfig.copy(this.requestConfig).setProxy(proxy).build(); } // voorgond feature info response type final String mType = config.getInitParameter("featureInfoType"); if (LOGGER.isDebugEnabled()) { LOGGER.debug("voorgrond kaartlagen mimetype: " + mType); } if ((mType != null) && (mType.length() > 0)) { type = CONVERTER_TYPE.valueOf(mType); } }
From source file:be.fedict.eid.applet.service.impl.handler.ClientEnvironmentMessageHandler.java
public void init(ServletConfig config) throws ServletException { this.secureRandom = new SecureRandom(); this.secureRandom.setSeed(System.currentTimeMillis()); String hostname = config.getInitParameter(HelloMessageHandler.HOSTNAME_INIT_PARAM_NAME); if (null != hostname) { this.includeHostname = true; }/*from w w w.j ava 2 s .c o m*/ String inetAddress = config.getInitParameter(HelloMessageHandler.INET_ADDRESS_INIT_PARAM_NAME); if (null != inetAddress) { this.includeInetAddress = true; } String channelBindingServerCertificate = config .getInitParameter(HelloMessageHandler.CHANNEL_BINDING_SERVER_CERTIFICATE); if (null != channelBindingServerCertificate) { this.serverCertificateChannelBinding = true; } String channelBindingService = config.getInitParameter(HelloMessageHandler.CHANNEL_BINDING_SERVICE); if (null != channelBindingService) { this.serverCertificateChannelBinding = true; } }
From source file:org.getobjects.servlets.WOServletAdaptor.java
protected String valueFromServletConfig(final ServletConfig _cfg, final String _key) { String an = _cfg.getInitParameter(_key); if (an != null) return an; final ServletContext sctx = _cfg.getServletContext(); if (sctx == null) return null; /*/* w w w .j a va 2 s . c o m*/ * This is specified in web.xml like: * <context-param> * <param-name>WOAppName</param-name> * <param-value>com.zideone.HelloWorld.HelloWorld</param-value> * </context-param> */ if ((an = sctx.getInitParameter(_key)) != null) return an; if ((an = (String) sctx.getAttribute(_key)) != null) return an; return an; }
From source file:org.hyperic.lather.server.LatherServlet.java
private String getReqCfg(ServletConfig cfg, String prop) throws ServletException { String res;/*from w w w. j a va 2 s. c o m*/ if ((res = cfg.getInitParameter(prop)) == null) { throw new ServletException("init-param '" + prop + "' not set"); } return res; }
From source file:org.pentaho.telemetry.web.TelemetryServlet.java
/** * Initializes the servlet.//from www . java 2 s. co m */ public void init(ServletConfig config) throws ServletException { super.init(config); Enumeration initParameterNames = config.getInitParameterNames(); Map<String, String> params = new HashMap<String, String>(); while (initParameterNames.hasMoreElements()) { String name = (String) initParameterNames.nextElement(); String value = config.getInitParameter(name); params.put(name, value); } serializer.setup(params); }
From source file:com.liferay.petra.doulos.servlet.DoulosServlet.java
@Override public void init(ServletConfig servletConfig) throws ServletException { try {//from ww w .j av a2 s . c om registerDoulosRequestProcessors(); } catch (Exception e) { throw new ServletException(e); } String validIpsString = servletConfig.getInitParameter("validIps"); if (validIpsString != null) { _validIps = validIpsString.split(","); } else { _validIps = new String[0]; } }
From source file:GuestBookServlet.java
/** * Provides the servlet with the chance to get runtime configuration values * and initialize itself. For a database servlet, you want to grab the * driver name, URL, and any connection information. For this example, I * assume a driver that requires a user name and password. For an example of * more database independent configuration, see Chapter 4. * /*from w w w . ja va 2 s . com*/ * @param cfg * the servlet configuration information * @throws javax.servlet.ServletException * could not load the specified JDBC driver */ public void init(ServletConfig cfg) throws ServletException { super.init(cfg); { String user, pw; driverName = cfg.getInitParameter("gb.driver"); jdbcURL = cfg.getInitParameter("gb.jdbcURL"); user = cfg.getInitParameter("gb.user"); if (user != null) { connectionProperties.put("user", user); } pw = cfg.getInitParameter("gb.pw"); if (pw != null) { connectionProperties.put("password", pw); } try { driver = (Driver) Class.forName(driverName).newInstance(); } catch (Exception e) { throw new ServletException("Unable to load driver: " + e.getMessage()); } } }
From source file:org.redhat.jboss.httppacemaker.ProxyServlet.java
@Override public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); String doLogStr = servletConfig.getInitParameter(P_LOG); if (doLogStr != null) { this.doLog = Boolean.parseBoolean(doLogStr); }/*ww w . j ava2s .com*/ targetUri = buildURI(retrieveParameterFromContext(servletConfig, P_TARGET_URI)); HttpParams hcParams = new BasicHttpParams(); String hcParamName = ClientPNames.HANDLE_REDIRECTS; hcParams.setParameter(hcParamName, ReflectUtils .invokeValueOfOnString(getServletConfig().getInitParameter(hcParamName), Boolean.class)); proxyClient = createHttpClient(hcParams); }
From source file:org.openlaszlo.servlets.responders.ResponderXMLDATA.java
@Override synchronized public void init(String reqName, ServletConfig config, Properties prop) throws ServletException, IOException { // Cache should only be initialized once. if (!mIsInitialized) { // Initialize data cache String cacheDir = config.getInitParameter("lps.dxcache.directory"); if (cacheDir == null) { cacheDir = prop.getProperty("dxcache.directory"); }//from w w w. j a v a 2s . co m if (cacheDir == null) { cacheDir = LPS.getWorkDirectory() + File.separator + "dxcache"; } File cache = checkDirectory(cacheDir); mLogger.info("Data Cache is at " + cacheDir); //------------------------------------------------------------ // Support for new style data response //------------------------------------------------------------ try { mCache = new XMLDataCache(cache, prop); } catch (IOException e) { throw new ServletException(e.getMessage()); } mIsInitialized = true; } super.init(reqName, config, mCache, prop); }
From source file:be.milieuinfo.core.proxy.controller.ProxyServlet.java
@Override public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); String doLogStr = servletConfig.getInitParameter(P_LOG); if (doLogStr != null) { this.doLog = Boolean.parseBoolean(doLogStr); }/*from w ww .j av a 2 s .c o m*/ try { targetUri = new URI(servletConfig.getInitParameter("targetUri")); } catch (Exception e) { throw new RuntimeException("Trying to process targetUri init parameter: " + e, e); } HttpParams hcParams = new BasicHttpParams(); readConfigParam(hcParams, ClientPNames.HANDLE_REDIRECTS, Boolean.class); proxyClient = createHttpClient(hcParams); }