JSP内置对象——response

response对象
response对象包含了响应客户端的有关信息,但在JSP中很少使用它。它是HttpServletResponse类的实例。response对象具有页面作用域,即访问一个页面时,该页面内的response对象只能对这次访问有效,其他页面的response对象对当前页面无效。常用方法如下:
String getCharacterEncoding() 返回响应用的是何种字符编码
void setContentType(String type) 设置响应的MIME类型
PrintWriter getWriter() 返回可以向客户端输出字符的一个对象(注意比较:PrintWriter与内置out对象的区别)
sendRedirect(java.lang.String location) 重新定向客户端的请求

sendRedirect()方法:请求重定向,相当于将请求跳转到一个新的页面当中去了。

原文地址:https://www.cnblogs.com/moonlightpoet/p/5599669.html