jsp页面后退问题

 说明存在三个jsp页面page1,page2,page3
通过page1查询得到page2页面,通过page2页面的链接得到page3页面
现在要后退,当在page3后退的时候,要把page2中的下面脚本删掉,否则就会报页面已经过期
<%
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
%>


2007-5-31 15:24 hope822
在JSP页面中,点后退按钮时,显示页面过期或操作超时之类的错误,如何做

我是用java开发的网站,数据库用的是mysql,请问,在JSP页面中,点后退按钮时,显示页面过期或操作超时之类的错误  ,
  总之显示不出页面内容,不能回到之前的页面继续操作了,这样的效果是怎么做出来的?

请高手指点,最好有代码,谢谢!
2007-5-31 16:07 赛扬
在之前的页面顶端写
<%
//禁止缓存
response.setHeader("Catch-Control","no-store");
response.setHeader("Pramga","no-catch");
response.setDateHeader("Expires",0);
%>
2007-5-31 16:23 hope822
回复 #2 赛扬 的帖子

多谢,我晚上回去试一下!;-)
2007-5-31 22:40 hope822
回复 #2 赛扬 的帖子

我试了,可是没成功!

我再说一下我要的功能:
我现在是通过后台的登陆界面进入后台,当点“退出”时,退出到后台登陆界面。此时,我再点IE浏览器上的后退按钮时,却仍能进入后台,继续进行操作,这当然不是我们所希望得到的效果。

请问, 在退出后,如何限制“后退”之后就不能再进入后台页面了,只能再登陆才能进去!

如果还是你说的这段代码的话,能否再请详细说一下代码放置位置,我把它放在html外,head里,body里,这几个地方都试了,好像都没有达到效果,还请再指点一下;如果不是,请再说一种方法,谢谢!
2007-5-31 23:40 SinNeR
之前你没说清楚,让赛扬理解错了。
通过session来控制。
用户登陆时,在session中写入用户信息,退出的时候清空session。
这样在操作页面通过判断session就可以知道当前的用户是否合法。
2007-6-1 08:43 赛扬
接SinNeR:
比如在登录表单提交后的页面,写入
<%
session.setAttribute("admin","1");//向session发送字符串变量admin,值为"1"
%>
然后通过链接或response.sendRedirect("....要转向到的页面名称....");转向到你的后台程序页面

在后台程序页面写入
<%
String admin = (String)session.getAttribute("admin");
if(admin!=null){
  //在这里正常显示登录后应显示的内容
}else{
  //这里就要报错了,未登录或已超时,显示提示信息然后N秒后自动转向到登录页面
}
%>
2007-6-1 14:12 hope822
回复 #6 赛扬 的帖子

谢谢啊
问题解决了。
这样点后退就会显示页面已过期。
但怎么能使那个后退的记忆功能没有啊!就是不能点那个后退键啊!
谢谢啊!
2007-6-1 14:15 hope822
回复 #6 赛扬 的帖子

这种方式应该是这样解决!
<%
//禁止缓存
response.setHeader("Catch-Control","no-store");
response.setHeader("Pramga","no-catch");
response.setDateHeader("Expires",0);
%>
但我用了没起作用!
是不是我放的地方不对,还是什么问题?
2007-6-1 15:54 赛扬
用禁止缓存配合session即可

以下两篇贴子供你参考
[url]http://bbs.blueidea.com/thread-701496-1-1.html[/url]
[url]http://bbs.blueidea.com/thread-1556412-1-1.html[/url]
2007-6-1 21:21 hope822
回复 #9 赛扬 的帖子

现在知道用禁止缓存配合session可以做到。
我在退出时把success设置为2。
<c:if test="${success == 2}">
<div class="chaoshi">
<h1> 您已没有权限,请返回重新登陆! </h1>
<a href="<%=request.getContextPath()%>/admin/index.jsp">返回,请点这里</a>
</div>
但我用禁止缓存的代码并没起作用?
<%
//禁止缓存
response.setHeader("Catch-Control","no-store");
response.setHeader("Pramga","no-catch");
response.setDateHeader("Expires",0);
%>
现在是点后退之后还可以看到页面的显示,只有点页面的按钮之后才出现
                         您已没有权限,请返回重新登陆!
我哪弄错了?谢了啊!
2007-6-2 12:51 hope822
还请再次指点一下,在此先谢过拉!
2007-6-2 13:18 asp910
你那些是在服务器端执行的,后退时是没有向服务器请求的
看到的页面可能是浏览器之前缓存在Temporary Internet Files目录下的
清理一下缓存测试一下
另外session权限判断最好放在Filter下,然后配置过滤的url,这样方便一些

 


<%@page contentType="text/html;charset=gb2312" language="java"%>
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@page import="com.fsti.doms.core.model.DOMSGlobalConstant" %>
<%
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
%>
<html>
<head><html:base/>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<link href="../css/style.css" type="text/css" rel="stylesheet">
<script src="../js/public.js" language="javascript"></script>
<script language="javascript" src="../js/checkAll.js"></script>
<script language="javascript" src="../js/calendar.js"></script>

<script src='<%=request.getContextPath()%>/dwr/engine.js'></script>
<script src='<%=request.getContextPath()%>/dwr/util.js'></script>
<script src='<%=request.getContextPath()%>/dwr/interface/StaffService.js'></script>
<script src="../js/DWRUtil.js" language="javascript"></script>
<style>
body,table,td{
font-size:12px;
}
</style>

<script language="javaScript">
function showDiv()
{
 document.all.mydiv.style.display="none";
}
function time_delay()
{
  setTimeout("showDiv();",10000);
}

function searchStaff(){  
    var o = window.event.srcElement.parentElement.parentElement;
    window.document.all.rowNum1.value = o.rowIndex;   
   window.document.all.cellNum.value = window.event.srcElement.parentElement.cellIndex;   
      
  window.open('simpleStaffSearch.jsp','','scrollbars=yes,resizable=yes,width=600,height=450,left=50,top=100');
 }

function checkData(){
 if(check('c2')){
 if(document.all.item.value == ""){
  alert("请选择项目编号!");
  return false;
 }
  if(confirm("料单可能需要重新打印,是否确定批量项目修改?")) {
    document.all.refer.value='正在操作,请稍候...';
    document.all.refer.disabled=true;
  document.theForm.submit()
 }}
 else{
  alert('请选择要项目信息修改的料单!')
        }
}
function init(){
var now = new Date();
var year = now.getYear();
var month = now.getMonth() + 1;
var date = now.getDate();

var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();

CurrentTime = "";
CurrentTime += year + "-";
CurrentTime += month + "-";
CurrentTime += date ;
CurrentTime +=" ";
sT=CurrentTime;

if(document.theForm)
document.theForm.operDate.value=sT;
}
</script>

</head>

<body οnkeydοwn="shieldKey()"οncοntextmenu="rightKey();" topmargin="0" marginheight="0" leftmargin="0" marginwidth="0" onLoad="init();time_delay()">
<table width="100%" border="0" cellpadding="0" cellspacing="0" height="25">
  <tr><td class="titlebar1">项目信息更改列表</td></tr>
  <logic:notPresent name="resultBillList" scope="request">
  <tr><td class="tipbar3">查无数据</td></tr>
  </logic:notPresent>
</table>
<br/>
<div style="display:block;" id="mydiv">
 <logic:present name="allsucc" scope="request">
   <p class="tipbar3">批量项目信息更改成功!</p>
 </logic:present>
 <logic:present name="succ" scope="request">
   <p class="tipbar3">料单操作成功!</p>
 </logic:present>
</div>
<logic:present name="resultBillList" scope="request">
<form action="batchModifyItemForBillAction.do" method="get" name="theForm">
<table id="result" class="tablecolor1" cellspacing="0" cellpadding="3" width="100%" align="center">
<tbody>
<tr>
 <th nowrap width="3%"><input type="checkbox"  name="c2all" onClick="CheckAll('c2','c2all')">全选</th>
 <th nowrap width="3%">序号</th>
 <th align="center" width="15%" nowrap>申请单编号</th>
 <th align="center" width="15%" nowrap>正式单编号</th>
 <th align="center" width="17%" nowrap>申请单开单时间</th>
 <th align="center" width="8%" nowrap>申请人</th>
 <th align="center" width="15%" nowrap>项目编号</th>
 <th align="center" width="15%" nowrap>项目名称</th>
 <th align="center" width="15%" nowrap>工程队名称</th>
 <th align="center" width="12%" nowrap>总金额</th> 
 <th align="center" width="15%" nowrap>料单状态</th>
 </tr>
  <logic:iterate id="item" name="resultBillList" scope="request" indexId="index">
  <tr οnmοuseοver=setCol1(this) οnmοuseοut=setCol2(this)>
    <td align="center"><input type="checkbox" name="c2" value="<bean:write name="item" property="billId"/>"></td>
    <td align="center" nowrap><font color="red"><%=index.intValue()+1%></font></td>
    <td align="center" nowrap><a href="toShowBillForItemModifyAction.do?billId=<bean:write name="item" property="billId"/>&billType=<bean:write name="billType"/>"><bean:write name="item" property="applyCode"/></a></td>
    <td align="center" nowrap><a  href="toShowBillForItemModifyAction.do?billId=<bean:write name="item" property="billId"/>&billType=<bean:write name="billType"/>"><bean:write name="item" property="billCode"/></a></td>
 <td align="center" nowrap><a  href="toShowBillForItemModifyAction.do?billId=<bean:write name="item" property="billId"/>&billType=<bean:write name="billType"/>"><bean:write name="item" property="applyDate"/></a></td>
 <td align="center" nowrap><a  href="toShowBillForItemModifyAction.do?billId=<bean:write name="item" property="billId"/>&billType=<bean:write name="billType"/>"><bean:write name="item" property="materialMan.staffName"/></a></td>
 <td align="center" nowrap><a  href="toShowBillForItemModifyAction.do?billId=<bean:write name="item" property="billId"/>&billType=<bean:write name="billType"/>">
  <logic:notEmpty  name="item" property="item">
     <bean:write name="item" property="item.itemCode"/>
 </logic:notEmpty>
 </a></td>
 <td align="center" nowrap><a  href="toShowBillForItemModifyAction.do?billId=<bean:write name="item" property="billId"/>&billType=<bean:write name="billType"/>">
 <logic:notEmpty  name="item" property="item">
    <bean:write name="item" property="item.itemName"/>
 </logic:notEmpty>
 </a></td>
 
 <td align="center" nowrap><a  href="toShowBillForItemModifyAction.do?billId=<bean:write name="item" property="billId"/>&billType=<bean:write name="billType"/>">
 <logic:notEmpty  name="item" property="engineer">
    <bean:write name="item" property="engineer.engineerName"/>
 </logic:notEmpty>
 </a></td>
 
 <!-- 
 <td align="center" nowrap><a  href="toShowBillForItemModifyAction.do?billId=<bean:write name="item" property="billId"/>&billType=<bean:write name="billType"/>">
       <logic:equal name="movebill" value="movebill">
       <logic:notEmpty name="item" property="outStoreHouse">
              <bean:write name="item" property="outStoreHouse.storeHouseName"/>
       </logic:notEmpty>
       </logic:equal>
       <logic:notEmpty  name="item" property="storeHouse">
       <bean:write name="item" property="storeHouse.storeHouseName"/>
     </logic:notEmpty></a></td>
     -->
 <td align="center" nowrap><a href="toShowBillForItemModifyAction.do?billId=<bean:write name="item" property="billId"/>&billType=<bean:write name="billType"/>">
          <script language="javaScript">
           document.write(formatFloat(<bean:write name="item" property="sum"/>,2));
          </script> 
 </a></td>
 <td align="center" nowrap><a  href="toShowBillForItemModifyAction.do?billId=<bean:write name="item" property="billId"/>&billType=<bean:write name="billType"/>"><bean:write name="item" property="currentStatus.statusName"/></td>
  </tr>
</logic:iterate>

</tbody>
</table>
<table id="billTable" class="tablecolor1" cellspacing="0" cellpadding="3" width="100%" align="center">
 <tr>
  <td align="right" nowrap>项目编号:</td>
  <td nowrap>
   <input type="hidden" name="item" value="">
   <input type="text" name="itemCode" value="" readonly size="30">
   <input type="button" class=sBtn1 value="..."  onClick="window.open('itemSearch.jsp','','scrollbars=yes,resizable=yes,width=800,height=500,left=50,top=100')"/><font class='red'>&nbsp;*&nbsp;</font></td>
  <td align="right" nowrap>项目名称:</td>
  <td><input type="text" name="itmeName" value="" size="40" readonly  size="30"></td>
 </tr>
 <tr>
  <td align="right" nowrap>项目经理:</td>
  <td nowrap>
   <input type="hidden" name="itemManager" value="">
   <input type="text" readonly name="itemManagerName" value=""  size="30">
   <input type="button" class=sBtn1  value="..." onClick="searchStaff();" style='cursor:hand'/></td>                   
 </tr>
</table>
<p style="margin-left:20px;">  <input name="operDate" type="text" size="15" οnfοcus="calendar()">
<input type="button" class=btn1 name="refer" value="批量项目更改" onClick="checkData();"></p>
<input type="hidden" name="billType" value="<bean:write name="billType"/>">
<input type="hidden" name="billTypeId" value="" />
</form>
</logic:present>
<br/>
<input type="hidden" name="rowNum" value="" />
<input type="hidden" name="rowNum1" value="" />
<input type="hidden" name="cellNum" value="" />
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值