1 <%@ page language="java" contentType="text/html; charset=UTF-8"
2 pageEncoding="UTF-8"%>
3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
4 <html>
5 <head>
6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
7 <title>Insert title here</title>
8 </head>
9 <body>
10 <%--request对象(post方式) --%>
11 <form action="NewFile2.jsp" method="post"><%--用form表单的方式提交数据参数,规定form表单为method="post"方式--%>
12 名称<input type="text" name="name">
13 密码<input type="password" name="password">
14 <input type="submit" value="提交">
15 </form>
16 </body>
17 </html>
1 <%@ page language="java" contentType="text/html; charset=UTF-8"
2 pageEncoding="UTF-8"%>
3
4 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5 <html>
6 <head>
7 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
8 <title>Insert title here</title>
9 </head>
10 <body>
11 <%
12 String name=new String(request.getParameter("name").getBytes("ISO-8859-1"),"UTF-8");
13 String password=request.getParameter("password");
14 out.print("<br>接收的参数name="+name);
15 out.print("<br>接收的参数password="+password+"<br>");
16 //请求转发的属性setAttribute,可以放置对象
17 request.setAttribute("aaa", name);//setAttribute("参数名", 转发的内容或对象)
18 %>
19 <jsp:forward page="NewFile4.jsp"></jsp:forward><%--转发到的地址 --%>
20 </body>
21 </html>
1 <%@ page language="java" contentType="text/html; charset=UTF-8"
2 pageEncoding="UTF-8"%>
3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
4 <html>
5 <head>
6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
7 <title>Insert title here</title>
8 </head>
9 <body>
10 <%
11 String a=request.getAttribute("aaa").toString();//接收请求转发的内容
12 out.print("收到的内容name:"+a);
13 %>
14 </body>
15 </html>