List of usage examples for javax.servlet ServletConfig getInitParameter
public String getInitParameter(String name);
From source file:com.kesdip.license.web.servlet.UpdateServlet.java
/** * Initialize {@link HibernateTemplate} and the actualUpdateRoot. * /*from w w w . java 2s.co m*/ * @see javax.servlet.GenericServlet#init(javax.servlet.ServletConfig) */ @Override public void init(ServletConfig config) throws ServletException { servletContext = config.getServletContext(); WebApplicationContext springCtx = WebApplicationContextUtils .getRequiredWebApplicationContext(servletContext); hibernateTemplate = (HibernateTemplate) springCtx.getBean("hibernateTemplate"); actualUpdateRoot = config.getInitParameter("updateSiteRoot"); }
From source file:uk.ac.cam.caret.sakai.rwiki.tool.RWikiServlet.java
public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); ServletContext sc = servletConfig.getServletContext(); wac = WebApplicationContextUtils.getWebApplicationContext(sc); headerPreContent = servletConfig.getInitParameter("headerPreContent"); headerScriptSource = servletConfig.getInitParameter("headerScriptSource"); footerScript = servletConfig.getInitParameter("footerScript"); try {//from w ww. j a va2s . c om boolean logResponse = "true".equalsIgnoreCase(servletConfig.getInitParameter("log-response")); TimeLogger.setLogResponse(logResponse); } catch (Exception ex) { } try { boolean logFullResponse = "true".equalsIgnoreCase(servletConfig.getInitParameter("log-full-response")); TimeLogger.setLogFullResponse(logFullResponse); } catch (Exception ex) { } String basePath = servletConfig.getServletContext().getRealPath("/"); dispatcher = new MapDispatcher(sc); }
From source file:org.jabsorb.JSONRPCServlet.java
/** * Called by the container when the servlet is initialized. * Check for optional configuration parameters. * <p>//w w w .j a va2 s. co m * At this time, only gzip_threshold is looked for. * </p><p> * If it is found, and a valid Integer is specified, then that is used * for the GZIP_THRESHOLD. * </p><p> * If an invalid Integer is specified, * then the GZIP_THRESHOLD is set to -1 which disables GZIP compression. * </p><p> * The gzip_threshold indicates the response size at which the servlet will attempt to gzip the response * if it can. * </p><p> * Set this to -1 if you want to disable gzip compression for some reason, * or if you have another filter or other mechanism to handle gzipping for you. * </p><p> * Set this to 0 to attempt to gzip all responses from this servlet. * otherwise, set it to the minimum response size at which gzip compression is attempted. * </p><p> * <b>NOTE:</b> if the browser making the request does not accept gzip compressed content, * or the result of gzipping would cause the response size to be larger (this could happen * with very small responses) then the content will be returned without gzipping, regardless. * </p><p> * of this setting, so it is very reasonable idea to set this to 0 for maximum bandwidth * savings, at the (very minor) expense of having the server attempt to gzip all responses. * </p> * @param config ServletConfig from container. * @throws ServletException if something goes wrong during initialization. */ public void init(ServletConfig config) throws ServletException { super.init(config); String gzipThresh = config.getInitParameter("gzip_threshold"); if (gzipThresh != null && gzipThresh.length() > 0) { try { JSONRPCServlet.GZIP_THRESHOLD = Integer.parseInt(gzipThresh); } catch (NumberFormatException n) { log.debug("could not parse " + gzipThresh + " as an integer... defaulting to -1 (gzip compression off)"); JSONRPCServlet.GZIP_THRESHOLD = -1; } } log.debug("GZIP_THRESHOLD is " + JSONRPCServlet.GZIP_THRESHOLD); if (JSONRPCServlet.GZIP_THRESHOLD == -1) { log.debug("Gzipping is turned OFF. No attempts will be made to gzip content from this servlet."); } else if (JSONRPCServlet.GZIP_THRESHOLD == 0) { log.debug("All responses will be Gzipped when gzipping results in a smaller response size."); } else { log.debug("Responses over this size will be Gzipped when gzipping results in a smaller response size."); } }
From source file:org.openlaszlo.servlets.responders.ResponderDATA.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.dcache.directory"); if (cacheDir == null) { cacheDir = prop.getProperty("dcache.directory"); }//from w w w. j av a 2 s .com if (cacheDir == null) { cacheDir = LPS.getWorkDirectory() + File.separator + "dcache"; } File cache = checkDirectory(cacheDir); mLogger.info( /* (non-Javadoc) * @i18n.test * @org-mes="Data Cache is at " + p[0] */ org.openlaszlo.i18n.LaszloMessages.getMessage(ResponderDATA.class.getName(), "051018-54", new Object[] { cacheDir })); //------------------------------------------------------------ // Support for new style data response //------------------------------------------------------------ try { mCache = new DataCache(cache, prop); } catch (IOException e) { throw new ServletException(e.getMessage()); } mIsInitialized = true; } super.init(reqName, config, mCache, prop); }
From source file:com.liferay.arquillian.DeployerServlet.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); ServletContext servletContext = config.getServletContext(); if (servletContext instanceof BundleReference) { _bundle = ((BundleReference) servletContext).getBundle(); }//from w ww. j av a 2 s . c o m _contextPathHeader = GetterUtil.getString(config.getInitParameter("contextPathHeader"), BUNDLE_CONTEXT_PATH); _deployerServletInstallLocation = GetterUtil .getString(config.getInitParameter("deployerServletInstallLocation"), DEPLOYER_SERVLET_LOCATION); _installTimeout = GetterUtil.getLong(config.getInitParameter("installTimeout"), TIMEOUT); }
From source file:be.fedict.eid.idp.webapp.ProtocolEntryServlet.java
private String getRequiredInitParameter(ServletConfig config, String initParamName) throws ServletException { String value = config.getInitParameter(initParamName); if (null == value) { throw new ServletException(initParamName + " init-param required"); }// w ww .j ava2 s .com return value; }
From source file:uk.co.bubobubo.web.HttpClientProxy.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 w w . j a v a 2 s. c o m*/ try { Properties properties = new Properties(); properties.load(Thread.currentThread().getContextClassLoader() .getResourceAsStream("properties/default.properties")); targetUri = new URI(properties.getProperty("proxy.sesame.url")); } 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); }
From source file:org.hippoecm.repository.LoggingServlet.java
private String getInitParameter(ServletConfig config, String paramName, String defaultValue) { String initValue = config.getInitParameter(paramName); if (initValue != null && initValue.length() != 0) { return initValue; } else {/*from w ww . j av a 2s . co m*/ return defaultValue; } }
From source file:uk.ac.ebi.phenotype.web.proxy.ExternalUrlConfiguratbleProxyServlet.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 w w. j a v a 2 s . c om*/ 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(); proxyClient = createHttpClient(hcParams); // Use the system http/https proxy if defined if (System.getProperty("http.proxyHost") != null && System.getProperty("http.proxyPort") != null) { String host = System.getProperty("http.proxyHost"); String portString = System.getProperty("http.proxyPort"); System.out.println("host=" + host + " port=" + portString); readConfigParam(hcParams, ClientPNames.HANDLE_REDIRECTS, Boolean.class); HttpHost proxy = new HttpHost(System.getProperty("http.proxyHost"), Integer.parseInt(portString), "http"); proxyClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); } }