Servlet --Response

HttpSesponseServlet

(HttpSesponseServlet object is the server response object, the object encapsulates data sent to the client, sending the first response, the response status code transmission method)


 

Setting response header, in the manner of a key-yalue key set, if the presence of the same key, the value of the value will cover

response.setHeader("x1","x2");
response.setHeader("x1","x22");

 

 

Setting response header, in the manner of a key-yalue key set, if the presence of the same key, the value will not be overwritten by the values

response.addHeader("hello","word");
response.addHeader("hello","word");

 

 

Setup Response Status Code

response.sendError(404,"not found");

 

 

The server returns the object data to be rendered in accordance with the requirements of a certain format, HTML format will only be an identification tag

response.setContentType("text/java");
response.getWriter().write("<b>java is easy</b>");
 

 

 

Guess you like

Origin www.cnblogs.com/-xsw000/p/12632121.html