[/url] [url=file:///F:/资料/文字资料/j2ee-1.4_doc/apidocs/overview-summary.html]Overview
Class
JavaTM 2 Platform
Ent. Ed. v1.4
PREV CLASS NEXT CLASS
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
javax.servlet
Class GenericServletjava.lang.Object
javax.servlet.GenericServlet
All Implemented Interfaces: Serializable, Servlet, ServletConfig Direct Known Subclasses: HttpServlet public abstract class GenericServlet extends Object implements Servlet, ServletConfig, SerializableDefines a generic, protocol-independent servlet. To write an HTTP servlet for use on the Web, extend HttpServlet instead. 定义了一个一般的,与协议无关的servlet。为了写一个HTTP servlet在Web上使用,应当继承HttpServlet。
GenericServlet implements the Servlet and ServletConfig interfaces. GenericServlet may be directly extended by a servlet, although it's more common to extend a protocol-specific subclass such as HttpServlet. GenericServlet实现了Servlet和ServletConfig接口。GenericServlet可以直接被servlet继承,尽管继承一个指定协议的子类比如HttpServlet更常用。
GenericServlet makes writing servlets easier. It provides simple versions of the lifecycle methods init and destroy and of the methods in the ServletConfig interface. GenericServlet also implements the log method, declared in the ServletContext interface. GenericServlet使得写servlet更容易。它提供了生命周期方法init、destroy和ServletConfig接口方法的简单版本。 GenericServlet也实现了在ServletContext接口中声明的log方法。
To write a generic servlet, you need only override the abstract service method. 写一个generic servlet,你只需要重写抽象方法service。
Version: $Version$ Author: Various See Also: Serialized FormConstructor Summary
Does nothing. 不做任何事。
Method Summary
void
destroy()
Called by the servlet container to indicate to a servlet that the servlet is being taken out of service. 由servlet容器调用,表示servlet正被清除出服务。
getInitParameter(String name)
Returns a String containing the value of the named initialization parameter, or null if the parameter does not exist. 返回命名的初始化参数的对应String值,如果参数不存在返回null。
Returns the names of the servlet's initialization parameters as an Enumeration of String objects, or an empty Enumeration if the servlet has no initialization parameters. 返回以String对象的Enumeration形式的servlet初始化参数名称,如果servlet不含初始化参数,返回一个空Enumeration。
Returns this servlet's ServletConfig object. 返回servlet的ServletConfig对象。
Returns a reference to the ServletContext in which this servlet is running. 返回正在运行的servlet的ServletContext的引用。
Returns information about the servlet, such as author, version, and copyright. 返回servlet的信息,例如作者、版本和版权。
Returns the name of this servlet instance. 返回servlet实例的名称。
void
init()
A convenience method which can be overridden so that there's no need to call super.init(config). 能被重写的简便方法,以至于不需调用super.init(config)。
void
init(ServletConfig config)
Called by the servlet container to indicate to a servlet that the servlet is being placed into service. 由servlet容器调用,表示servlet正被放入服务。
void
Writes the specified message to a servlet log file, prepended by the servlet's name. 将详细信息写入servlet日志文件,含servlet名称。
void
log(String message, Throwable t)
Writes an explanatory message and a stack trace for a given Throwable exception to the servlet log file, prepended by the servlet's name. 将说明信息和给出的Throwable异常堆栈跟踪写入servlet日志文件,含servlet名称。
abstract void
service(ServletRequest req, ServletResponse res)
Called by the servlet container to allow the servlet to respond to a request. 由servlet容器调用,允许servlet响应请求。
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
GenericServletpublic GenericServlet()
Does nothing. All of the servlet initialization is done by one of the init methods. 不做任何事。所有servlet初始化都由某个init方法完成。
Method Detail
destroypublic void destroy()
Called by the servlet container to indicate to a servlet that the servlet is being taken out of service. See Servlet.destroy(). 由servlet容器调用,表示servlet正被清除出服务。参见Servlet.destroy()。
Specified by: destroy in interface ServletgetInitParameterpublic String getInitParameter(String name)
Returns a String containing the value of the named initialization parameter, or null if the parameter does not exist. See ServletConfig.getInitParameter(java.lang.String). 返回命名的初始化参数的对应String值,如果参数不存在返回null。参见ServletConfig.getInitParameter(java.lang.String)。 This method is supplied for convenience. It gets the value of the named parameter from the servlet's ServletConfig object. 该方法为了简便起见提供,从servlet的ServletConfig对象中获得指定名称的参数值。
Specified by: getInitParameter in interface ServletConfigParameters: name - a String specifying the name of the initialization parameter String,指定初始化参数的名称 Returns: String a String containing the value of the initalization parameter 包含初始化参数值的StringgetInitParameterNamespublic Enumeration getInitParameterNames()
Returns the names of the servlet's initialization parameters as an Enumeration of String objects, or an empty Enumeration if the servlet has no initialization parameters. See ServletConfig.getInitParameterNames(). 返回以String对象的Enumeration形式的servlet初始化参数名称,如果servlet不含初始化参数,返回一个空Enumeration。参见ServletConfig.getInitParameterNames()。 This method is supplied for convenience. It gets the parameter names from the servlet's ServletConfig object. 该方法为了简便起见提供,从servlet的ServletConfig对象中获得参数名称。
Specified by: getInitParameterNames in interface ServletConfigReturns: Enumeration an enumeration of String objects containing the names of the servlet's initialization parameters String对象的枚举,包含初始化变量的名称getServletConfigpublic ServletConfig getServletConfig()
Returns this servlet's ServletConfig object. 返回servlet的ServletConfig对象。
Specified by: getServletConfig in interface ServletReturns: ServletConfig the ServletConfig object that initialized this servlet 初始化servlet的ServletConfig对象 See Also: Servlet.init(javax.servlet.ServletConfig)getServletContextpublic ServletContext getServletContext()
Returns a reference to the ServletContext in which this servlet is running. See ServletConfig.getServletContext(). 返回正在运行的servlet的ServletContext的引用。参见ServletConfig.getServletContext()。 This method is supplied for convenience. It gets the context from the servlet's ServletConfig object. 该方法为了简便起见提供,从servlet的ServletConfig对象中获得上下文。
Specified by: getServletContext in interface ServletConfigReturns: ServletContext the ServletContext object passed to this servlet by the init method 通过init方法传递给servlet的ServletContext对象 See Also: ServletContextgetServletInfopublic String getServletInfo()
Returns information about the servlet, such as author, version, and copyright. By default, this method returns an empty string. Override this method to have it return a meaningful value. See Servlet.getServletInfo(). 返回servlet的信息,例如作者、版本和版权。 默认返回空字符串。重写本方法,可以让它返回一个有意义的值。参见Servlet.getServletInfo()。
Specified by: getServletInfo in interface ServletReturns: String information about this servlet, by default an empty string 关于servlet的信息,墨认为空字符串initpublic void init(ServletConfig config)
throws ServletException
Called by the servlet container to indicate to a servlet that the servlet is being placed into service. See Servlet.init(javax.servlet.ServletConfig). 由servlet容器调用,表示servlet正被放入服务。参见Servlet.init(javax.servlet.ServletConfig)。 This implementation stores the ServletConfig object it receives from the servlet container for later use. When overriding this form of the method, call super.init(config). 该实现保存了从servlet容器接收到的ServletConfig对象留作后用。重写该方法时,应调用super.init(config)。
Specified by: init in interface ServletParameters: config - the ServletConfig object that contains configutation information for this servlet ServletConfig对象,包含servlet的配置信息 Throws: ServletException - if an exception occurs that interrupts the servlet's normal operation 如果异常发生,阻止servlet的正常操作时抛出 See Also: UnavailableExceptioninitpublic void init()
throws ServletException
A convenience method which can be overridden so that there's no need to call super.init(config). 能被重写的简便方法,以至于不需调用super.init(config)。 Instead of overriding init(ServletConfig), simply override this method and it will be called by GenericServlet.init(ServletConfig config). The ServletConfig object can still be retrieved via getServletConfig(). 代之重写init(ServletConfig),可以简单重写本方法,它将会被GenericServlet.init(ServletConfig config)调用。 ServletConfig对象仍然可以通过getServletConfig()获得。
Throws: ServletException - if an exception occurs that interrupts the servlet's normal operation 如果异常发生,阻止servlet的正常操作时抛出logpublic void log(String msg)
Writes the specified message to a servlet log file, prepended by the servlet's name. See ServletContext.log(String). 将详细信息写入servlet日志文件,含servlet名称。参见ServletContext.log(String)。
Parameters: msg - a String specifying the message to be written to the log file String,指定写入日志文件的信息logpublic void log(String message,
Throwable t)
Writes an explanatory message and a stack trace for a given Throwable exception to the servlet log file, prepended by the servlet's name. See ServletContext.log(String, Throwable). 将说明信息和给出的Throwable异常堆栈跟踪写入servlet日志文件,含servlet名称。参见ServletContext.log(String, Throwable)。
Parameters: message - a String that describes the error or exception 描述错误或异常的String t - the java.lang.Throwable error or exception java.lang.Throwable错误或异常servicepublic abstract void service(ServletRequest req,
ServletResponse res)
throws ServletException,
Called by the servlet container to allow the servlet to respond to a request. See Servlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse). 由servlet容器调用,允许servlet响应请求。参见Servlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)。 This method is declared abstract so subclasses, such as HttpServlet, must override it. 该方法被声明为抽象,所以子类,比如HttpServlet必须重载它。
Specified by: service in interface ServletParameters: req - the ServletRequest object that contains the client's request 包含客户端请求的ServletRequest对象 res - the ServletResponse object that will contain the servlet's response 包含客户端响应的ServletResponse对象 Throws: ServletException - if an exception occurs that interferes with the servlet's normal operation occurred 如果异常发生,阻止servlet的正常操作时抛出 IOException - if an input or output exception occurs 如果输入输出异常发生时抛出getServletNamepublic String getServletName()
Returns the name of this servlet instance. See ServletConfig.getServletName(). 返回servlet实例的名称。 参见ServletConfig.getServletName()。
Specified by: getServletName in interface ServletConfigReturns: the name of this servlet instance servlet实例名称[/url][url=file:///F:/资料/文字资料/j2ee-1.4_doc/apidocs/overview-summary.html]Overview
Class
JavaTM 2 Platform
Ent. Ed. v1.4
PREV CLASS NEXT CLASS
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Submit a bug or feature Copyright 2003 Sun Microsystems, Inc. All rights reserved.