常见接口
servlet方法有:
void destory()
ServletConfig getServletConfig()
void init(ServletConfig config)
void service (ServletRequest req,ServletResponse res)
ServletConfig是servlet容器初始化servlet时传给init()方法的参数。
RequestDispatcher(请求转发)
void forward(ServletRequest req,ServletResponse res)
void include(ServletRequest req,ServletResponse res)
ServletRequest(an object to provide client request information to a servlet)
object getAttribute(String name)
void setAttribute(String name,object o)
String getParameter(String name)
RequestDispatcher getRequestDispacher(String path)
ServletContext getServletContext()
SerlvetResponse(an object to assist a servlet in sending a response to the client. )
PrintWriter getWriter()
void setCharacterEncoding()
ServletContext(a set of methods that a servlet uses to communicate with its servlet container)
void addListener(String className)
常见类
GenericServlet(实现servlet接口)(a generic, protocol-independent servlet)
方法与servlet基本一致
Httpservlet(an abstract class to be subclassed to create an HTTP servlet suitable for a Web site)
void doGet(HttpServletRequest req,HttpServletResponse res)
void doPost(HttpServletRequest req,HttpServletResponse res)
封装了init和destoty方法,在底层servlet中实现