servlet接口中的方法:
void init(ServletConfig config) throws ServletException:第一次加载servlet时仅调用一次。
ServletConfig getServletConfig():返回传递到init()方法的ServletConfig对象。
void service(ServletRequest request,ServletResponse response) throws :处理request对象中描述的请求,使用response对象返回请求结果。
ServletException, IOException
String getServletInfo():返回描述servlet的一个字符串。
void destory():当servlet将要卸载时由sevlet引擎调用。
GenericServlet类中的方法:
void destory():
String getInitParameter(String name):返回具有指定名称的初始化参数值。通过调用config.getInitParameter(name)实现。
Enumeration getInitParameterNames():返回所有初始化参数的一个枚举类型值。如果没有,则返回空枚举。
ServletConfig getServletConfig():返回传递到init()方法中的config对象
ServletContext getServletContext():返回在config对象中引用的ServletContext
String getServletInfo():返回空字符串
void init(ServletConfig config) throws ServletException:在一实例变量中保存config对象
void init() throws ServletException:
void log(String msg):编写注册servlet的入口。为此调用servlet上下文的log方法。
void log(String msg,Throwable t):
abstract void service(Request request,Response response):由servlet引擎调用为请求对象描述的请求提供服务。必须被子类覆盖
throws ServeltException,IOException
String getServletName():返回在web应用发布描述其(web.xml)中指定的servlet名字
HttpServlet类中的方法
void doGet(HttpServletRequest request,HttpServletResponse response):处理GET请求。
throws SerlvetException,IOException
void doPost(HttpServletRequest request,HttpServletResponse response):处理POST请求。
throws SerlvetException,IOException
void doPut(HttpServletRequest request,HttpServletResponse response):处理PUT求情,本方法中请求URI指出被载入的文件位置
throws SerlvetException,IOException
void doDelete(HttpServletRequest request,HttpServletResponse response):处理DELETE请求,清楚URI指出资源被删除
throws SerlvetException,IOException