本文整理汇总了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>");
}
示例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;
}
}
示例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);
}