【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:负 ...
随机推荐
- 2018-2-13-C#-解析-sln-文件
title author date CreateTime categories C# 解析 sln 文件 lindexi 2018-2-13 17:23:3 +0800 2018-2-13 17:23 ...
- H3C ping命令的输出
- H3C配置文件的显示与维护
- CF809D Hitchhiking in the Baltic States
CF809D Hitchhiking in the Baltic States CF809D 长度为n的序列{xi},n<=3e5,范围在(li,ri)之间,求LIS最长是多长g(i,l)表示前 ...
- Java之String类常用API
目录 Java之String类常用API char chatAt(int index) int length() char[] toCharArray() String(char value[]) S ...
- 图解Go里面的sync.Map了解编程语言核心实现源码
基础筑基 在大多数语言中原始map都不是一个线程安全的数据结构,那如果要在多个线程或者goroutine中对线程进行更改就需要加锁,除了加1个大锁,不同的语言还有不同的优化方式, 像在java和go这 ...
- 机器学习之——集成算法,随机森林,Bootsing,Adaboost,Staking,GBDT,XGboost
集成学习 集成算法 随机森林(前身是bagging或者随机抽样)(并行算法) 提升算法(Boosting算法) GBDT(迭代决策树) (串行算法) Adaboost (串行算法) Stacking ...
- kotlin + springboot 整合redis,Redis工具类编写及单元测试
参考自: https://www.cnblogs.com/zeng1994/p/03303c805731afc9aa9c60dbbd32a323.html 1.maven依赖 <?xml ve ...
- [LINQ2Dapper]最完整Dapper To Linq框架(八)---导航属性
目录 [LINQ2Dapper]最完整Dapper To Linq框架(一)---基础查询 [LINQ2Dapper]最完整Dapper To Linq框架(二)---动态化查询 [LINQ2Dapp ...
- 洛谷$P3308\ [SDOI2014]LIS$ 网络流
正解:网络流 解题报告: 传送门$QwQ$ 恩先不考虑关于那个附加属性的限制,考虑这题怎么做? 首先这题从名字开始就让人忍不住联想起网络流24题里的那个最长不下降子序列?于是同样考虑预处理一个$f$呗 ...