jsp内置对象之response对象
response对象:
代码:
<%@ page language="java" import="java.util.*,java.io.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
response.setContentType("text/html;chartset=utf-8");//设置响应的MIMI类型
//必须写在最前面,因为后面有HTML代码
out.println("<h1>response内置对象</h1>");
out.println("<hr>");
//out.flush();//清空缓冲区
PrintWriter outer=response.getWriter();//获得输出流对象
outer.println("大家好,我是response生成的输出流");
//response.sendRedirect("reg.jsp");//请求重定向
%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
response.setContentType("text/html;chartset=utf-8");//设置响应的MIMI类型
//必须写在最前面,因为后面有HTML代码
out.println("<h1>response内置对象</h1>");
out.println("<hr>");
//out.flush();//清空缓冲区
PrintWriter outer=response.getWriter();//获得输出流对象
outer.println("大家好,我是response生成的输出流");
//response.sendRedirect("reg.jsp");//请求重定向
%>
结果:
大家好,我是response生成的输出流