Jsp 的请求与重定向
来源:互联网 发布:淘宝详情页模板视频 编辑:程序博客网 时间:2024/05/17 05:12
forward_and_redirect_A.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<!--
4. 请求的转发和重定向:
1). 本质区别: 请求的转发只发出了一次请求, 而重定向则发出了两次请求.
具体:
①. 请求的转发: 地址栏是初次发出请求的地址.
请求的重定向: 地址栏不再是初次发出的请求地址. 地址栏为最后响应的那个地址
②. 请求转发: 在最终的 Servlet 中, request 对象和中转的那个 request 是同一个对象.
请求的重定向: 在最终的 Servlet 中, request 对象和中转的那个 request 不是同一个对象.
③. 请求的转发: 只能转发给当前 WEB 应用的的资源
请求的重定向: 可以重定向到任何资源.
④. 请求的转发: / 代表的是当前 WEB 应用的根目录
请求的重定向: / 代表的是当前 WEB 站点的根目录.
-->
<h2>forward_and_redirect_A</h2>
<a href="forward_B.jsp">forward_B</a>
<br><br>
<a href="redirect_B.jsp">redirect_B</a>
</body>
</html>
forward_B.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
request.getRequestDispatcher("/forward_and_redirect_C.jsp").forward(request, response);
//request.getRequestDispatcher("http://baidu.com").forward(request, response);
%>
</body>
</html>
redirect_B.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
response.sendRedirect("forward_and_redirect_C.jsp");
//response.sendRedirect("http://baidu.com");
%>
</body>
</html>
forward_and_redirect_C.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h2>forward_and_redirect_C</h2>
</body>
</html>
- Jsp 的请求与重定向
- Jsp请求转发与请求重定向的区别
- JSP中请求重定向与请求转发的区别
- jsp 中重定向与请求转发的区别
- Jsp的请求转发与重定向区别
- JSP请求的转发与重定向——day10
- Jsp&Servlet 重定向、请求转发与绝对路径的问题
- jsp重定向与请求转发
- JSP——请求重定向与请求转发
- JSP内置对象——请求转发与请求重定向的区别
- Jsp 重定向、请求转发
- Jsp 重定向、请求转发
- Jsp 重定向、请求转发
- JSP中请求重定向和请求转发的区别
- jsp--------请求重定向和请求转发的区别
- JSP中请求转发何请求重定向的区别
- 请求转发与重定向的区别
- 请求转发与重定向的区别:
- Js 闭包传参 setInterval 多次
- Spring框架学习记录
- JAVA利用HttpClient进行POST请求(HTTPS)
- 【模板】搜索
- RobotFrameWork(二)Ride简单使用及快捷键
- Jsp 的请求与重定向
- js的笔记11.16
- Android堆栈管理的类ActivityStackManager
- iOS画柱状图,折线图
- Eclipse中LogCat如何打开
- MFC 自定义子线程新建对话框的数据传输问题 -- 以及由此对MFC的一些思考
- 机器学习 - 感知机(PLA, Perceptron Learning Algorithm)
- android:windowSoftInputMode
- 线性代数的本质-20160614总结