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


Java ServletConfig.getServletName方法代碼示例

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


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

示例1: doGet

import javax.servlet.ServletConfig; //導入方法依賴的package包/類
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
ServletConfig config = getServletConfig();

String lname = config.getServletName();
String driver_Class = config.getInitParameter("driver_Class");
String driver_URL = config.getInitParameter("driver_URL");
String db_User_Name = config.getInitParameter("db_User_Name");
String db_Password = config.getInitParameter("db_Password");
Enumeration<String> e = config.getInitParameterNames();
String param_Names = "";
while(e.hasMoreElements()) {
param_Names = param_Names+e.nextElement()+"<br>";
}

out.println("<html>");
out.println("<body>");
out.println("<h3>Servlet Configuration Details</h3>");
out.println("<table border='1'>");
out.println("<tr><th>Parameter Names</th><th>Parameter Values</th></tr>");
out.println("<tr><td>driver_Class</td><td>"+driver_Class+"</td></tr>");
out.println("<tr><td>driver_URL</td><td>"+driver_URL+"</td></tr>");
out.println("<tr><td>db_User_Name</td><td>"+db_User_Name+"</td></tr>");
out.println("<tr><td>db_Password</td><td>"+db_Password+"</td></tr>");
out.println("<tr><td>Parameter Names</td><td>"+param_Names+"</td></tr>");
out.println("<tr><td>Servlet Logical Name</td><td>"+lname+"</td></tr>");
out.println("</table></body></html>");
}
 
開發者ID:pratikdimble,項目名稱:Servlet_Config_Interface,代碼行數:30,代碼來源:ConfigServlet.java

示例2: init

import javax.servlet.ServletConfig; //導入方法依賴的package包/類
/**
 * Sets instance variables.
 * <P>
 * Modified from Craig R. McClanahan's InvokerServlet
 * </P>
 *
 * @param config                    a <code>ServletConfig</code> object
 *                                  containing the servlet's
 *                                  configuration and initialization
 *                                  parameters
 *
 * @exception ServletException      if an exception has occurred that
 *                                  interferes with the servlet's normal
 *                                  operation
 */
public void init(ServletConfig servletConfig)
    throws ServletException
{
    super.init(servletConfig);

    if (!Library.isInitialized()) {
        // try to load the library.
        try {
            Library.initialize(null);
        } catch(Exception e) {
            e.printStackTrace();
        }
    }

    if (!Library.isInitialized())
        throw new UnavailableException
            (sm.getString("handler.missing"));

    this.servletConfig = servletConfig;

    // Verify that we were not accessed using the invoker servlet
    String servletName = servletConfig.getServletName();
    if (servletName == null)
        servletName = "";
    if (servletName.startsWith("org.apache.catalina.INVOKER."))
        throw new UnavailableException
            ("Cannot invoke Handler through the invoker");


    // Set our properties from the initialization parameters
    String value = null;
    try {
        value = servletConfig.getInitParameter("debug");
        debug = Integer.parseInt(value);
        scriptPathPrefix =
            servletConfig.getInitParameter("scriptPathPrefix");
        value = servletConfig.getInitParameter("bufferSize");
        if (value != null) {
            bufferSize = Integer.parseInt(value);
            if (bufferSize < 1024)
                bufferSize = 1024;
            log("init: bufferSize set to " + bufferSize);
        }
    } catch (Throwable t) {
        // Nothing.
    }
    log("init: loglevel set to " + debug);

    value = servletConfig.getInitParameter("parameterEncoding");
    if (value != null) {
        parameterEncoding = value;
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:69,代碼來源:Handler.java

示例3: FakeServletConfig

import javax.servlet.ServletConfig; //導入方法依賴的package包/類
/**
 * Copy the values from another {@link ServletConfig} so we can modify them.
 * @param servletConfig
 */
public FakeServletConfig(ServletConfig servletConfig) {
    this.name = servletConfig.getServletName();
    this.servletContext = servletConfig.getServletContext();
    this.initParameters = getInitParametersInServletConfig(servletConfig);
}
 
開發者ID:devefx,項目名稱:validator-web,代碼行數:10,代碼來源:FakeServletConfig.java


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