请求转发 定义一个response的jsp文件
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.util.*,java.io.*"%>
<%
out.println("<h1>response内置对象</h1>");
out.println("<hr>");
//out.flush();//清空缓冲区
//获得输出流对象
PrintWriter outer=response.getWriter();
outer.println("我是歌谣");
//请求重定向
//response.sendRedirect("requset.jsp");
//请求转发
request.getRequestDispatcher("requset.jsp").forward(request, response);
%>
定义一个test08的jsp文件<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1>request对象</h1>
<hr>
<form action="response.jsp" name="regForm" method="post">
<table>
<tr>
<td>用户名:</td>
<td><input type="text" name="username"/></td>
</tr>
<tr>
<td>爱好:</td>
<input type="checkbox" name="favorite" value="read"/>读书
<input type="checkbox" name="favorite" value="music"/>音乐
<input type="checkbox" name="favorite" value="movie"/>电影
<input type="checkbox" name="favorite" value="internet"/>上网
</tr>
<tr>
<td colspan="2"><input type="submit" value="登录"></td>
</tr>
</table>
</form>
<br>
<br>
<a href="requset.jsp?username=lisi">url</a>
</body>
</html>