【javaWeb】sendRedirect和forward原理及区别总结
- <span style="font-size: medium;"><%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
- <%
- String path = request.getContextPath();
- String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
- %>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <base href="<%=basePath%>">
- <title>My JSP 'end.jsp' starting page</title>
- <meta http-equiv="pragma" content="no-cache">
- <meta http-equiv="cache-control" content="no-cache">
- <meta http-equiv="expires" content="0">
- <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
- <meta http-equiv="description" content="This is my page">
- <!--
- <link rel="stylesheet" type="text/css" href="styles.css">
- -->
- </head>
- <body>
- name:${param.name}, sex:${requestScope.sex}, the end page!
- </body>
- </html>
- </span>
- <span style="font-size: medium;"> <%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
- <%
- String path = request.getContextPath();
- String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
- %>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <base href="<%=basePath%>">
- <title>My JSP 'first.jsp' starting page</title>
- <meta http-equiv="pragma" content="no-cache">
- <meta http-equiv="cache-control" content="no-cache">
- <meta http-equiv="expires" content="0">
- <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
- <meta http-equiv="description" content="This is my page">
- <!--
- <link rel="stylesheet" type="text/css" href="styles.css">
- -->
- </head>
- <body>
- This is my JSP page. <br>
- <%
- request.setAttribute("sex", "man");
- <span style="color: #0000ff;"> response.sendRedirect("/studyProject/myforward/end2.jsp");//绝对路径</span>
- %>
- </body>
- </html>
- </span>
- <span style="font-size: medium;"><%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
- <%
- String path = request.getContextPath();
- String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
- %>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <base href="<%=basePath%>">
- <title>My JSP 'first.jsp' starting page</title>
- <meta http-equiv="pragma" content="no-cache">
- <meta http-equiv="cache-control" content="no-cache">
- <meta http-equiv="expires" content="0">
- <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
- <meta http-equiv="description" content="This is my page">
- <!--
- <link rel="stylesheet" type="text/css" href="styles.css">
- -->
- </head>
- <body>
- This is my JSP page. <br>
- <%
- request.setAttribute("sex", "man");
- %>
- <span style="color: #0000ff;"> <jsp:forward page="/myforward/end.jsp"></span>
- <jsp:param value="tomzhang" name="name"/>
- </jsp:forward>
- </body>
- </html>
- </span>
- <span style="font-size: medium;"><%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
- <%
- String path = request.getContextPath();
- String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
- %>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <base href="<%=basePath%>">
- <title>My JSP 'end.jsp' starting page</title>
- <meta http-equiv="pragma" content="no-cache">
- <meta http-equiv="cache-control" content="no-cache">
- <meta http-equiv="expires" content="0">
- <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
- <meta http-equiv="description" content="This is my page">
- <!--
- <link rel="stylesheet" type="text/css" href="styles.css">
- -->
- </head>
- <body>
- name:${param.name}, sex:${requestScope.sex}, the end page!
- </body>
- </html>
- </span>
【javaWeb】sendRedirect和forward原理及区别总结的更多相关文章
- sendRedirect()和forward()方法的区别
sendRedirect()和forward()方法的区别 之前好像曾经整理过,但忘了放在哪里了,好像压根就没整理过,博客里也没有,故今天重新整理一下. 我们知道页面之间的跳转有两种方式:重定向与转发 ...
- java 中sendredirect()和forward()方法的区别
一.文章1 HttpServletResponse.sendRedirect与RequestDispatcher.forward方法都可以实现获取相应URL资源. sendRedirect实现请求重 ...
- HttpServlet RequestDispatcher sendredirect和forward
Servlet的框架是由两个Java包组成:javax.servlet和javax.servlet.http. 在javax.servlet包中定义了所有的Servlet类都必须实现或扩展的的通用接口 ...
- sendredirect()和forward()的区别 (转)
sendRedirect() 和forward()的区别 HttpServletResponse.sendRedirect与RequestDispatcher.forward方法都可以实现获取相应UR ...
- JavaWeb中监听器+过滤器+拦截器区别、配置和实际应用
JavaWeb中监听器+过滤器+拦截器区别.配置和实际应用 1.前沿上一篇文章提到在web.xml中各个元素的执行顺序是这样的,context-param-->listener-->fil ...
- (转发)RequestDispatcher的include()方法和forward()方法的区别
forward(): 该方法用于将请求从一个Servlet传递给服务器上的另外的Servlet.JSP页面或者是HTML文件. 在Servlet中,可以对请求做一个初步的处理,然后调用这个方法,将请求 ...
- HashMap,Hashtable,ConcurrentHashMap 和 synchronized Map 的原理和区别
HashMap 是否是线程安全的,如何在线程安全的前提下使用 HashMap,其实也就是HashMap,Hashtable,ConcurrentHashMap 和 synchronized Map 的 ...
- atitit.交换机 汇聚上联、网络克隆和标准共享的原理与区别
atitit.交换机 汇聚上联.网络克隆和标准共享的原理与区别 1. 标准共享(标准化模式)1 2. 汇聚上联trunk1 2.1. 使用场合1 2.2. 背景1 2.3. 实现原理2 3. 网络克隆 ...
- cacti,zabbix,nagios各自原理及区别
cacti,zabbix,nagios各自原理及区别 Taxing祥 0人评论 19462人阅读 2017-09-24 00:23:54 cacti原理: 1,构件(步骤): net_snmp:负 ...
随机推荐
- Linux 内核链表头数据结构
链表头必须在使用前用 INIT_LIST_HEAD 宏来初始化. 一个"要做的事情"的链表头可能声 明并且初始化用: struct list_head todo_list; INI ...
- webstorm一键格式化为Eslint标准
- HBase写过程详解
1首次读写流程图 2 首次写基本流程 (1)客户端发起PUT请求,Zookeeper返回hbase:meta所在的region server (2)去(1)返回的server上,根据rowkey去hb ...
- python字符串(str)
# value = "raitOrEi" # v = value.capitalize()#首字母大写 # print(v) # v1 = v.casefold()#全部变小写,不 ...
- OSI协议介绍
应用层 为网络用户或应用程序提供各种服务,代表协议有Telnet,FTP,HTTP,SNMP等 表示层 负责所传输的信的语法和语义,用于处理再多个通信系统之间交换信息的表示方式,代表协议有ASCII, ...
- 对EntityViewInfo的理解
1,EntityViewInfo常常用作bos中接口参数,来做查询用,其中包含了FilterInfo(过滤).Selector(指定属性)以及Sorter(排序) SelectorItemColl ...
- POJ - 3177 Redundant Paths 说说连通分量吧
----我想说说双联通分量还有割点和桥 1.割点(一个点,如果没有这一个点,图就会变得不连通) 2.桥(一条边,断开这条边就会让图不连通) 3.点双连通(没割点的图) 4.边双连通(没桥的图) 5.割 ...
- redis 和 memcached 有什么区别?redis 的线程模型是什么?为什么 redis 单线程却能支撑高并发?
redis 和 memcached 有啥区别? redis 支持复杂的数据结构 redis 相比 memcached 来说,拥有更多的数据结构,能支持更丰富的数据操作.如果需要缓存能够支持更复杂的结构 ...
- centos安装pip,zipimport.ZipImportError报错
安装pip下载pip安装包wget https://bootstrap.pypa.io/get-pip.py 执行以下报错 python get-pip.py ##报错内容(zipimport.Zip ...
- Kafka 集群在马蜂窝大数据平台的优化与应用扩展
马蜂窝技术原创文章,更多干货请订阅公众号:mfwtech Kafka 是当下热门的消息队列中间件,它可以实时地处理海量数据,具备高吞吐.低延时等特性及可靠的消息异步传递机制,可以很好地解决不同系统间数 ...