Servlet common interface and the relationship between classes

Paste the common interfaces and classes of Servlet, and the relationship between them:

1. servlet interface The main methods
of the interface directly or indirectly implemented by all servlets : void init(ServletConfig sc) ServletConfig getServletConfig() String getServletInfo(); void service(ServletRequest req, ServletResponse resp) void destory() 2.HtppServlet abstract class it heavy The service method is written to provide different methods for different types of customer requests: doPost(), doGet() 3. ServletRequest interface and ServletResponse interface When a user request comes, the servlet container will create a ServletRequest object to encapsulate the request data, and create a ServletResponse object at the same time The main method of encapsulating the response data ServletRequest: Object getAttribute(String name) //Return the attribute value with the attribute name name Enumeration getAttributeNames() //Return all the attributes in the request void removeAttribute(String name)  void setAttribute(String name,Object obj) String getCharacterEncoding();
















String getParameter(String name)//Return the value of the request name parameter
Enumeration getParameterNames() 
ServletOutputStream getOutputStream() //Used to send the response to the client
PrintWrite getWrite() //Used to send character text to the client out.println( "daduh");
4.HttpServletRequest interface
Cookie[] getCookies();
HttpSession getSession();
5.HttpServletResponse interface
void addCookie(Cookie cookie);
6.HttpSession interface
String getId()
String getAttribute(String name)
void setAttribute(String name,Object obj)
Enumeration getAttributeNames()

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324738684&siteId=291194637