List of usage examples for javax.servlet ServletConfig getInitParameter
public String getInitParameter(String name);
From source file:org.efs.openreports.dispatcher.XMLADispatcher.java
protected String makeDataSourcesUrl(ServletConfig servletConfig) { String paramValue = servletConfig.getInitParameter(PARAM_DATASOURCES_CONFIG); // if false, then do not throw exception if the file/url // can not be found boolean optional = getBooleanInitParameter(servletConfig, PARAM_OPTIONAL_DATASOURCE_CONFIG); URL dataSourcesConfigUrl = null; try {/*from w ww . j a va2 s . com*/ if (paramValue == null) { // fallback to default String defaultDS = directoryProvider.getReportDirectory() + DEFAULT_DATASOURCE_FILE; File realPath = new File(defaultDS); if (realPath.exists()) { // only if it exists dataSourcesConfigUrl = realPath.toURI().toURL(); return dataSourcesConfigUrl.toString(); } else { return null; } } else if (paramValue.startsWith("inline:")) { return paramValue; } else { paramValue = Util.replaceProperties(paramValue, Util.toMap(System.getProperties())); if (LOGGER.isDebugEnabled()) { LOGGER.debug("XmlaServlet.makeDataSources: paramValue=" + paramValue); } // is the parameter a valid URL MalformedURLException mue = null; try { dataSourcesConfigUrl = new URL(paramValue); } catch (MalformedURLException e) { // not a valid url mue = e; } if (dataSourcesConfigUrl == null) { // see if its a full valid file path File f = new File(paramValue); if (f.exists()) { // yes, a real file path dataSourcesConfigUrl = f.toURI().toURL(); } else if (mue != null) { // neither url or file, // is it not optional if (!optional) { throw mue; } } return null; } return dataSourcesConfigUrl.toString(); } } catch (MalformedURLException mue) { throw Util.newError(mue, "invalid URL path '" + paramValue + "'"); } }
From source file:com.amalto.core.servlet.LogViewerServlet.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); String location = config.getInitParameter("logFile"); //$NON-NLS-1$ try {/* w w w . j a va2 s .c o m*/ file = getLogFile(location); } catch (FileNotFoundException e) { throw new ServletException(e.getMessage(), e); } String defaultMaxLinesString = config.getInitParameter("maxLinesByChunk"); //$NON-NLS-1$ defaultMaxLines = Integer.parseInt(defaultMaxLinesString); charset = config.getInitParameter("charset"); //$NON-NLS-1$ if (charset == null) { charset = Charset.defaultCharset().name(); } }
From source file:org.infoscoop.web.WidgetServlet.java
public void init(ServletConfig config) throws ServletException { defaultUid = config.getInitParameter("defaultUid"); if (defaultUid == null) defaultUid = "default"; super.init(config); }
From source file:cn.vlabs.duckling.vwb.ui.servlet.AbstractLoginServlet.java
@Override public void init(ServletConfig config) throws ServletException { String file = config.getInitParameter("configFile"); if (file == null) { throw new ServletException("Init parameter configFile which contains sso configuration is required."); }//w w w . jav a2 s. c o m principalKey = config.getInitParameter("principalKey"); if (principalKey == null) { principalKey = "umt.principal"; } String prefix = config.getInitParameter("prefix"); String realPath = config.getServletContext().getRealPath(file); Config config1 = loadConfig(realPath); copyToLocal(prefix, config1); }
From source file:com.qwazr.webapps.example.DocumentationServlet.java
@Override public void init(ServletConfig config) { String p = config.getInitParameter("remotePrefix"); if (!StringUtils.isEmpty(p)) remotePrefix = p;//from w w w. j a v a2s .com p = config.getInitParameter("indexFileNames"); if (!StringUtils.isEmpty(p)) indexFileNames = StringUtils.split(p, " "); p = config.getInitParameter("documentationPath"); if (!StringUtils.isEmpty(p)) documentationPath = new File(p); p = config.getInitParameter("freemarkerTool"); freemarkerTool = LibraryManager.getInstance().getLibrary(StringUtils.isEmpty(p) ? "freemarker" : p); p = config.getInitParameter("markdownTool"); markdownTool = LibraryManager.getInstance().getLibrary(StringUtils.isEmpty(p) ? "markdown" : p); p = config.getInitParameter("asciiDoctorTool"); asciiDoctorTool = LibraryManager.getInstance().getLibrary(StringUtils.isEmpty(p) ? "adoc" : p); p = config.getInitParameter("templatePath"); if (!StringUtils.isEmpty(p)) templatePath = p; }
From source file:org.infoscoop.web.WidgetConfServlet.java
public void init(ServletConfig config) throws ServletException { super.init(config); String cacheLifeTime = config.getInitParameter("cacheLifeTime"); try {/*from w w w. j ava 2s. c o m*/ if (cacheLifeTime != null) CACHE_LIFE_TIME = Integer.parseInt(cacheLifeTime); } catch (Exception e) { log.warn("cacheLifeTime must be a number. cacheLifeTime = " + cacheLifeTime); } if (log.isInfoEnabled()) log.info("cacheLifeTime = " + CACHE_LIFE_TIME + " minutes"); factory = SAXParserFactory.newInstance(); factory.setNamespaceAware(true); }
From source file:org.paxml.web.PaxmlServlet.java
@Override public void init(ServletConfig c) throws ServletException { try {/*w ww . j a v a 2 s. co m*/ String tagLibs = c.getInitParameter(CONFIG_TAG_LIB); if (tagLibs != null) { for (String lib : StringUtils.split(tagLibs, CONFIG_VALUE_SEP)) { Class clazz = Class.forName(lib.trim()); config.getTagLibs().add(clazz); } } String paxmlDir = c.getInitParameter(CONFIG_PAXML_DIR); if (paxmlDir != null) { for (String dir : StringUtils.split(paxmlDir, CONFIG_VALUE_SEP)) { dir = dir.trim(); if (!dir.isEmpty()) { config.getResources().addAll(LaunchModelBuilder.findResources(dir, null, null)); } } } else { config.getResources() .addAll(LaunchModelBuilder.findResources(new File(".").getAbsolutePath(), null, null)); } String resDir = c.getInitParameter(CONFIG_PAXML_DIR); if (resDir != null) { for (String dir : StringUtils.split(resDir, CONFIG_VALUE_SEP)) { dir = dir.trim(); if (!dir.isEmpty()) { resources.add(new File(dir)); } } } else { resources.add(new File(".")); } } catch (Exception e) { throw new ServletException("Cannot init paxml servlet", e); } }
From source file:alpine.servlets.FileSystemResourceServlet.java
/** * Overrides the servlet init method and loads sets the InputStream necessary * to load application.properties.//w ww . ja v a 2 s .c o m * @throws ServletException a general error that occurs during initialization */ @Override public void init(ServletConfig config) throws ServletException { super.init(config); String directory = config.getInitParameter("directory"); if (StringUtils.isNotBlank(directory)) { this.directory = directory; } String absolute = config.getInitParameter("absolute"); if (StringUtils.isNotBlank(absolute)) { this.absolute = BooleanUtil.valueOf(absolute); } }
From source file:de.micromata.genome.gwiki.web.dav.WebDavServlet.java
@Override public void init(ServletConfig config) throws ServletException { if (StringUtils.equals("true", config.getInitParameter("wordHtmlEdit")) == true) { wordHtmlEdit = true;/* ww w . j a va2 s . c om*/ } internalUserName = config.getInitParameter("internalUserName"); internalPass = config.getInitParameter("internalPass"); super.init(config); }
From source file:com.ctriposs.rest4j.server.Rest4JServlet.java
private boolean getUseAsync(ServletConfig servletConfig) { String useAsync = servletConfig.getInitParameter(USE_ASYNC_PARAM); if (useAsync != null) { return Boolean.parseBoolean(useAsync); } else {/*from w w w .j ava 2 s . co m*/ return servletConfig.getServletContext().getMajorVersion() >= 3; } }