當前位置: 首頁>>代碼示例>>Java>>正文


Java ServletContext.getInitParameterNames方法代碼示例

本文整理匯總了Java中javax.servlet.ServletContext.getInitParameterNames方法的典型用法代碼示例。如果您正苦於以下問題:Java ServletContext.getInitParameterNames方法的具體用法?Java ServletContext.getInitParameterNames怎麽用?Java ServletContext.getInitParameterNames使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.servlet.ServletContext的用法示例。


在下文中一共展示了ServletContext.getInitParameterNames方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: contextInitialized

import javax.servlet.ServletContext; //導入方法依賴的package包/類
public void contextInitialized(ServletContextEvent sce) {
    if (sce != null && sce.getServletContext() != null) {
        LOGGER.info("Context initialised, loading settings.");
        ServletContext context = sce.getServletContext();
        Properties properties = new Properties();
        Enumeration<String> names = context.getInitParameterNames();
        while (names.hasMoreElements()) {
            String name = names.nextElement();
            properties.put(name, context.getInitParameter(name));
        }
        CoreSettings coreSettings = new CoreSettings(
                properties,
                URI.create(properties.getProperty(CoreSettings.TAG_SERVICE_ROOT_URL) + "/" + properties.getProperty(CoreSettings.TAG_API_VERSION)).normalize().toString(),
                context.getAttribute(ServletContext.TEMPDIR).toString());
        context.setAttribute(TAG_CORE_SETTINGS, coreSettings);
        PersistenceManagerFactory.init(coreSettings);
        MqttManager.init(coreSettings);
        PersistenceManagerFactory.addEntityChangeListener(MqttManager.getInstance());
    }
}
 
開發者ID:kinota,項目名稱:kinota-server,代碼行數:21,代碼來源:ContextListener.java

示例2: xmlConversionServiceFactoryForServlets

import javax.servlet.ServletContext; //導入方法依賴的package包/類
/**
 *  Factory for use in Servlets to create an XMLConversionService using
 *  configurations found in the Servlet context parameters. This method also
 *  places the path to the XSL files directory in the servlet context under
 *  'xslFilesDirecoryPath', for use by the JavaXmlConverters. <p>
 *
 *  To configure a format converter that uses an XSL style sheet or Java class,
 *  the context param-name must begin with the either 'xslconverter' or
 *  'javaconverter' and must be unique. The param-value must be of the form
 *  'xslfile.xsl|[from format]\[to format]' or '[fully qualified Java
 *  class]|[from format]\[to format]'.
 *
 * @param  servletContext      The ServletContext
 * @param  xslFilesDirecory    The base directory where the XSL files are
 *      located
 * @param  xmlCachDirecory     The directory where the service will cache the
 *      converted XML files
 * @param  filterDeclarations  Set to true to filter out the XML and DTD
 *      declarations in the converted XML
 * @return                     The XMLConversionService
 * @exception  Exception       If error
 */
public static XMLConversionService xmlConversionServiceFactoryForServlets(
                                                                          ServletContext servletContext,
                                                                          File xslFilesDirecory,
                                                                          File xmlCachDirecory,
                                                                          boolean filterDeclarations)
	 throws Exception {

	// Set up an XML Conversion Service:

	// Place the xsl dir path in the Servlet context for use by the JavaXmlConverters
	servletContext.setAttribute("xslFilesDirecoryPath", xslFilesDirecory.getAbsolutePath());
	XMLConversionService xmlConversionService = null;
	xmlCachDirecory.mkdir();

	xmlConversionService =
		new XMLConversionService(xmlCachDirecory, filterDeclarations);

	// Add configured converters:
	Enumeration enumeration = servletContext.getInitParameterNames();
	String param;
	while (enumeration.hasMoreElements()) {
		param = (String) enumeration.nextElement();
		if (param.toLowerCase().startsWith("xslconverter")) {
			xmlConversionService.addXslConverterHelper(servletContext.getInitParameter(param), xslFilesDirecory);
		}
		if (param.toLowerCase().startsWith("javaconverter")) {
			xmlConversionService.addJavaConverterHelper(servletContext.getInitParameter(param), servletContext);
		}
	}
	return xmlConversionService;
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:54,代碼來源:XMLConversionService.java

示例3: doGet

import javax.servlet.ServletContext; //導入方法依賴的package包/類
/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	
		response.setContentType("text/html");
		//get the response writer
		PrintWriter out = response.getWriter();
		//initialise the servlet context
		ServletContext context = request.getServletContext();
		//get the context name
		String lname = context.getServletContextName();
		//initialise the parameters
		String a = context.getInitParameter("a");
		String b = context.getInitParameter("b");
		String c = context.getInitParameter("c");
		String d = context.getInitParameter("d");
		
		Enumeration<String> e1 = context.getInitParameterNames();
		String param_Names = "";
		//appending attr names to a string variable 
		while(e1.hasMoreElements()) {
		param_Names = param_Names + e1.nextElement()+"<br>";
		}
				//set the attribute
		context.setAttribute("x", "XXX");
		context.setAttribute("y", "YYY");
		context.setAttribute("z", "ZZZ");

		String x = (String)context.getAttribute("x");
		String y = (String)context.getAttribute("y");
		String z = (String)context.getAttribute("z");
			//get the attribute names
				Enumeration<String> e2 = context.getAttributeNames();
					String attr_Names = "";
						//appending attr names to a string variable 
					while(e2.hasMoreElements()) {
						attr_Names = attr_Names + e2.nextElement()+"<br>";
					}//while close
//html code to display
		out.println("<html>");
			out.println("<body>");
				out.println("<h3>Servlet Context Details<h3>");
					out.println("<table border='1'>");
						out.println("<tr><td colspan='2'>Parameters Details</td></tr>");
							out.println("<tr><td>a</td><td>"+a+"</td></tr>");
							out.println("<tr><td>b</td><td>"+b+"</td></tr>");
							out.println("<tr><td>c</td><td>"+c+"</td></tr>");
							out.println("<tr><td>d</td><td>"+d+"</td></tr>");
								out.println("<tr><td>Parameter Names</td><td>"+param_Names+"</td></tr>");
									out.println("<tr><td colspan='2'>Attributes Details</td></tr>");
										out.println("<tr><td>x</td><td>"+x+"</td></tr>");
										out.println("<tr><td>y</td><td>"+y+"</td></tr>");
										out.println("<tr><td>z</td><td>"+z+"</td></tr>");
											out.println("<tr><td>Attributes Names</td><td>"+attr_Names+"</td></tr>");
												out.println("<tr><td>Logical Name</td><td>"+lname+"</td></tr>");
												out.println("<tr><td>Foreign Context</td><td>"+context.getContext("/app8")+"</td></tr>");
												out.println("</table></body></html>");

		}
 
開發者ID:pratikdimble,項目名稱:Servlet_Context_Interface,代碼行數:61,代碼來源:ContextServlet.java

示例4: addContextParametersToSystemProperties

import javax.servlet.ServletContext; //導入方法依賴的package包/類
/**
 * Ajoute les paramètres de contexte aux propriétés systèmes, de manière à les rendre accessibles dans logback.xml
 * @param servletContext
 */
private void addContextParametersToSystemProperties(ServletContext servletContext) {
	Enumeration<String> e = servletContext.getInitParameterNames();
	while (e.hasMoreElements()) {
		String parameterName = e.nextElement();
		System.setProperty("context." + parameterName, servletContext.getInitParameter(parameterName));
	}
	System.setProperty(ConstanteUtils.STARTUP_INIT_FLYWAY, "");
}
 
開發者ID:EsupPortail,項目名稱:esup-ecandidat,代碼行數:13,代碼來源:Initializer.java

示例5: createInitParamMap

import javax.servlet.ServletContext; //導入方法依賴的package包/類
/**
 *
 * Creates the Map that maps init parameter name to single init
 * parameter value.
 **/
public static Map<String, String> createInitParamMap(PageContext pContext)
{
  final ServletContext context = pContext.getServletContext ();
  return new EnumeratedMap<String, String> ()
    {
      public Enumeration<String> enumerateKeys () 
      {
        return context.getInitParameterNames ();
      }

      public String getValue (Object pKey) 
      {
        if (pKey instanceof String) {
          return context.getInitParameter ((String) pKey);
        }
        else {
          return null;
        }
      }

      public boolean isMutable ()
      {
        return false;
      }
    };
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:32,代碼來源:ImplicitObjectELResolver.java


注:本文中的javax.servlet.ServletContext.getInitParameterNames方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。