天天看點

javax.servlet.Servlet接口

< DOCTYPE html PUBLIC -WCDTD XHTML StrictEN httpwwwworgTRxhtmlDTDxhtml-strictdtd>

servlet抽象集是javax.servlet.Servlet接口,它規定了必須由Servlet類實作由servlet引擎識别和管理的方法集。

Servlet接口的基本目标是提供生命期方法init()、service()和destroy()方法。

servlet接口中的方法       

void init(ServletConfit config)throws ServletException     在servlet被載入後和實施服務前由servlet引擎進行?次性調用。如果init()産生溢出UnavailableException,則servle退出服務。       

ServletConfig getServletConfig()     傳回傳遞到servlet的init()方法的ServletConfig對象       

void service(ServletRequest request, ServletResponse response)throws ServletException,IOException     處理request對象中描述的請求,使用response對象傳回請求結果       

String getServletInfo()         傳回描述servlet的一個字元串       

void destory()         當servlet将要解除安裝時由servlet引擎調用 #java專欄