List of usage examples for javax.servlet ServletConfig getInitParameter
public String getInitParameter(String name);
From source file:be.fedict.eid.dss.protocol.simple.client.SignatureResponseProcessorServlet.java
@Override public void init(ServletConfig config) throws ServletException { // flow// w w w. j a v a2 s . c o m LOG.debug("init"); this.iframe = null != config.getInitParameter(IFRAME_INIT_PARAM); this.nextPage = getRequiredInitParameter(config, NEXT_PAGE_INIT_PARAM); LOG.debug("next page: " + this.nextPage); this.cancelPage = config.getInitParameter(CANCEL_PAGE_INIT_PARAM); this.errorPage = getRequiredInitParameter(config, ERROR_PAGE_INIT_PARAM); LOG.debug("error page: " + this.errorPage); this.errorMessageSessionAttribute = getRequiredInitParameter(config, ERROR_MESSAGE_SESSION_ATTRIBUTE_INIT_PARAM); LOG.debug("error message session attribute: " + this.errorMessageSessionAttribute); // WS client config this.dssWSUrl = config.getInitParameter(DSS_WS_URL_INIT_PARAM); this.dssWSProxyHost = config.getInitParameter(DSS_WS_PROXY_HOST_INIT_PARAM); String dssWSProxyPortString = config.getInitParameter(DSS_WS_PROXY_PORT_INIT_PARAM); if (null != dssWSProxyPortString) { this.dssWSProxyPort = Integer.parseInt(dssWSProxyPortString); } if (null != this.dssWSUrl) { LOG.debug("DSS WS: " + this.dssWSUrl + " (proxy=" + this.dssWSProxyHost + ":" + this.dssWSProxyPort + ")"); } // Response Config this.signedDocumentSessionAttribute = config.getInitParameter(SIGNED_DOCUMENT_SESSION_ATTRIBUTE_INIT_PARAM); this.signatureResponseIdSessionAttribute = config .getInitParameter(SIGNATURE_RESPONSE_ID_SESSION_ATTRIBUTE_INIT_PARAM); this.signatureCertificateSessionAttribute = config .getInitParameter(SIGNATURE_CERTIFICATE_SESSION_ATTRIBUTE_INIT_PARAM); if (null == this.signedDocumentSessionAttribute && null == this.signatureResponseIdSessionAttribute) { throw new ServletException("Need \"" + SIGNED_DOCUMENT_SESSION_ATTRIBUTE_INIT_PARAM + "\" or \"" + SIGNATURE_RESPONSE_ID_SESSION_ATTRIBUTE_INIT_PARAM + "\" init params"); } String encodedServiceFingerprint = config.getInitParameter(SERVICE_FINGERPRINT_INIT_PARAM); byte[] serviceFingerprint; if (null != encodedServiceFingerprint) { LOG.debug("service fingerprint: " + encodedServiceFingerprint); try { serviceFingerprint = Hex.decodeHex(encodedServiceFingerprint.toCharArray()); } catch (DecoderException e) { throw new ServletException("service fingerprint decoding error: " + e.getMessage(), e); } } else { serviceFingerprint = null; } // Request Config this.targetSessionAttribute = config.getInitParameter(TARGET_SESSION_ATTRIBUTE_INIT_PARAM); this.signatureRequestSessionAttribute = config .getInitParameter(SIGNATURE_REQUEST_SESSION_ATTRIBUTE_INIT_PARAM); this.signatureRequestIdSessionAttribute = config .getInitParameter(SIGNATURE_REQUEST_ID_SESSION_ATTRIBUTE_INIT_PARAM); this.relayStateSessionAttribute = config.getInitParameter(RELAY_STATE_SESSION_ATTRIBUTE_INIT_PARAM); // runtime config this.signatureResponseServiceLocator = new ServiceLocator<SignatureResponseService>( SIGNATURE_RESPONSE_SERVICE_INIT_PARAM, config); // Construct response processor this.signatureResponseProcessor = new SignatureResponseProcessor(serviceFingerprint); }
From source file:snoopware.api.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 w w. j a v a2 s. c om try { targetUri = new URI(servletConfig.getInitParameter(P_TARGET_URI)); } 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:nl.b3p.commons.security.XmlSecurityDatabase.java
/** Initializes the servlet. *//*from w w w. ja v a 2 s .c o m*/ @Override public void init(ServletConfig config) throws ServletException { super.init(config); // log = LogFactory.getLog(this.getClass()); // Initialize Torque try { String configLocation = getServletContext().getRealPath(config.getInitParameter("config")); log("config pad: " + configLocation); FileReader fr = new FileReader(configLocation); if (fr == null) { if (log.isDebugEnabled()) { log.debug("config reader is null"); } } else { try { securityDatabase = WebappUsers.unmarshal(fr); } catch (MarshalException me) { log.error("MarshalException", me); } catch (ValidationException ve) { log.error("MarshalException", ve); } } } catch (Exception e) { log.error("Xml Security Database load exception", e); throw new UnavailableException("Cannot load xml security database"); } // Omzetten in gemakkelijk uitleesbare objecten if (securityDatabase != null && log != null) { if (log.isDebugEnabled()) { log.debug("Xml Database is not null."); } maxNumOfSessions = securityDatabase.getMaxsessions(); log.debug("Max number of active sessions: " + maxNumOfSessions + " (0 = no limit)"); userpasswords = new HashMap(); userroles = new HashMap(); int userCount = securityDatabase.getUserCount(); for (int i = 0; i < userCount; i++) { User aUser = null; try { aUser = securityDatabase.getUser(i); } catch (IndexOutOfBoundsException ioobe) { break; } if (aUser != null) { if (log.isDebugEnabled()) { log.debug("Init user: " + aUser.getUsername()); } userpasswords.put(aUser.getUsername(), aUser.getPassword()); String theRoles = aUser.getRoles(); if (theRoles == null || theRoles.length() == 0) { continue; } ArrayList roleList = new ArrayList(); int roleCount = securityDatabase.getRoleCount(); for (int j = 0; j < roleCount; j++) { Role aRole = null; try { aRole = securityDatabase.getRole(j); } catch (IndexOutOfBoundsException ioobe) { break; } if (aRole != null && theRoles.indexOf(aRole.getRolename()) >= 0) { roleList.add(aRole.getRolename()); if (log.isDebugEnabled()) { log.debug(" adding role: " + aRole.getRolename()); } } } userroles.put(aUser.getUsername(), roleList); } } initialized = true; if (log.isInfoEnabled()) { log.debug("Initializing Xml Security Database servlet"); } } else { System.out.println("XML Security Database servlet not initialized!"); } }
From source file:org.jbpm.designer.server.EditorHandler.java
public boolean doShowPDFDoc(ServletConfig config) { return Boolean.parseBoolean(System.getProperty(SHOW_PDF_DOC) == null ? config.getInitParameter(SHOW_PDF_DOC) : System.getProperty(SHOW_PDF_DOC)); }
From source file:net.nicoulaj.benchmark.mockwebapp.MockWebAppServlet.java
/** * Initialize the servlet.//from w ww .j a va 2s. c o m * <p/> * Loads the {@link #mockWebAppConfig} by looking up the {@link #MOCK_WEB_APP_CONF_PROPERTY} as a system property or init parameter, * and sets up a listener on the file changes. * * @param config the {@link ServletConfig}, optionally with a {@link #MOCK_WEB_APP_CONF_PROPERTY} parameter. * @throws ServletException if the {@link #MOCK_WEB_APP_CONF_PROPERTY} was neither defined as a system property nor an init parameter. */ @Override public void init(ServletConfig config) throws ServletException { super.init(config); // Locate the config file parameter. String configFilePath = System.getProperty(MOCK_WEB_APP_CONF_PROPERTY); if (configFilePath == null) configFilePath = config.getInitParameter(MOCK_WEB_APP_CONF_PROPERTY); if (configFilePath == null) throw new ServletException("No mock web app config file defined. Please define one using the '" + MOCK_WEB_APP_CONF_PROPERTY + "' system property or servlet init parameter."); // Setup the config file changes listener. try { fileMonitor = new DefaultFileMonitor(new ConfigFileListener()); fileMonitor.addFile(VFS.getManager().resolveFile(new File("."), configFilePath)); fileMonitor.start(); } catch (Exception e) { getServletContext().log( "Failed setting up config file changes listener, config file changes will not be taken into account", e); } // Load the config from the file. final File configFile = new File(configFilePath); try { mockWebAppConfig = MockWebAppConfig.Parser.parseConfig(configFile); getServletContext().log("Loaded config file " + configFilePath); } catch (Exception e) { getServletContext().log("Failed loading config, please replace it with a valid one", e); } }
From source file:be.integrationarchitects.web.dragdrop.servlet.impl.DragDropServlet.java
@Override public void init(ServletConfig servletConfig) throws ServletException { random = new SecureRandom(); String str_cfg = servletConfig.getInitParameter("cfg"); Class c = null;//from w ww . j a va2 s. co m try { c = Class.forName(str_cfg); cfg = (DragDropServletConfig) c.newInstance(); logger = cfg.getLogger(); //used in 500.jsp for error logging servletConfig.getServletContext().setAttribute("mycfg", cfg); } catch (Exception e) { System.err.println(e.getMessage()); throw new ServletException(e); } utils = new DragDropServletUtils(cfg.getFolder(), cfg.checkHash(), logger); logger.logDebug(".....................................Init drag drop servlet ok:" + str_cfg + ":" + cfg.getHandler() + ":" + cfg.getFolder()); }
From source file:net.morphbank.mbsvc3.webservices.Uploader.java
public void init(ServletConfig config) throws ServletException { super.init(config); folderPath = config.getInitParameter("filepath"); // setup persistence unit from parameter, if available RequestParams.initService(config);/*from www .j a va 2 s . c o m*/ }
From source file:org.ocpsoft.rewrite.servlet.config.proxy.ProxyServlet.java
public void init(ServletConfig servletConfig) throws ServletException { this.servletConfig = servletConfig; String doLogStr = servletConfig.getInitParameter(P_LOG); if (doLogStr != null) { this.doLog = Boolean.parseBoolean(doLogStr); }/*from w w w .j av a 2s . c o m*/ try { targetUriObj = new URI(servletConfig.getInitParameter(P_TARGET_URI)); } catch (Exception e) { throw new RuntimeException("Trying to process targetUri init parameter: " + e, e); } targetUri = targetUriObj.toString(); HttpParams hcParams = new BasicHttpParams(); readConfigParam(hcParams, ClientPNames.HANDLE_REDIRECTS, Boolean.class); proxyClient = createHttpClient(hcParams); }
From source file:org.apache.geronimo.daytrader.javaee6.web.TradeAppServlet.java
/** * Servlet initialization method./*from w w w . j a v a 2s . c om*/ */ public void init(ServletConfig config) throws ServletException { super.init(config); java.util.Enumeration en = config.getInitParameterNames(); while (en.hasMoreElements()) { String parm = (String) en.nextElement(); String value = config.getInitParameter(parm); TradeConfig.setConfigParam(parm, value); } try { if (TradeConfig.runTimeMode == TradeConfig.JDBC) { TradeJDBCDirect.init(); } else if (TradeConfig.runTimeMode == TradeConfig.JPA) { TradeJPADirect.init(); } else { TradeJEEDirect.init(); } } catch (Exception e) { Log.error(e, "TradeAppServlet:init -- Error initializing TradeDirect"); } }
From source file:org.jabsorb.ng.JSONRPCServlet.java
/** * Called by the container when the servlet is initialized. Check for * optional configuration parameters./*from w ww. j av a 2 s . c om*/ * <p> * 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. */ @Override public void init(final 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("init", "could not parse " + gzipThresh + " as an integer... defaulting to -1 (gzip compression off)"); JSONRPCServlet.GZIP_THRESHOLD = -1; } } log.debug("init", "GZIP_THRESHOLD is " + JSONRPCServlet.GZIP_THRESHOLD); if (JSONRPCServlet.GZIP_THRESHOLD == -1) { log.debug("init", "Gzipping is turned OFF. No attempts will be made to gzip content from this servlet."); } else if (JSONRPCServlet.GZIP_THRESHOLD == 0) { log.debug("init", "All responses will be Gzipped when gzipping results in a smaller response size."); } else { log.debug("init", "Responses over this size will be Gzipped when gzipping results in a smaller response size."); } }