JSP page bounce

Source: Internet
Author: User
Tags tld

Three JSP pages: page1, page2, and page3
The page2 page is obtained through page1 query, and the page3 page is obtained through the link of the page2 page.
Back now. When page3 is back, delete the following script in page2; otherwise, the page will be reported to have expired.
<%
Response. setheader ("Pragma", "No-Cache ");
Response. setheader ("cache-control", "No-Cache ");
Response. setdateheader ("expires", 0 );
%>

Hope822
When you click the back button on the JSP page, errors such as page expiration or operation timeout are displayed. How can this problem be solved?

I am a website developed using Java, and the database uses MySQL. On the JSP page, When you click the back button, an error such as page expiration or operation timeout is displayed,
In short, the page content is not displayed, and you cannot return to the previous page to continue operations. How can this effect be achieved?

Please kindly advise. It is best to have code. Thank you!
Sai Yang
Write at the top of the previous page
<%
// Disable caching
Response. setheader ("catch-control", "No-store ");
Response. setheader ("pramga", "No-catch ");
Response. setdateheader ("expires", 0 );
%>
Hope822
Reply #2 sai Yang's post

Thank you. I will try it later in the evening !; -)
Hope822
Reply #2 sai Yang's post

I tried it, but it failed!

Let me talk about the features I want:
I am now entering the background through the background login interface. When I click "exit", I will exit the background login interface. At this point, when I click the back button on IE, I can still enter the background and continue the operation. This is of course not what we want to achieve.

Excuse me, after exiting, how can I restrict the backend from accessing the background page? You can only log on to the backend page!

If you still talk about this piece of code, could you please elaborate on the Code placement location? I put it outside HTML, in head, in body, and tried it in these places, it doesn't seem to have any effect. Please give me some advice. If not, please try another method. Thank you!
Sinner
You didn't make it clear before, and it's wrong for Sai Yang to understand.
Control by session.
When a user logs in, the user information is written into the session, and the session is cleared when the user exits.
In this way, you can determine whether the current user is valid by checking the session on the Operation page.
Sai Yang
Sinner:
For example, on the page after the login form is submitted, write
<%
Session. setattribute ("admin", "1"); // send the string admin variable to the session. The value is "1"
%>
Then go to your background program page through the link or response. sendredirect ("... the name of the page to be redirected ...");

Write Data on the background program page
<%
String admin = (string) Session. getattribute ("admin ");
If (Admin! = NULL ){
// The information displayed after logon is displayed normally.
} Else {
// An error is reported here. If you have not logged on or timed out, a prompt is displayed. Then, the system automatically redirects to the logon page n seconds later.
}
%>
Hope822
Reply #6 sai Yang's post

Thank you.
The problem is solved.
In this way, the page will be displayed as expired.
But how can we make that back-up memory function unavailable! You just can't click that back key!
Thank you!
Hope822
Reply #6 sai Yang's post

This method should be solved in this way!
<%
// Disable caching
Response. setheader ("catch-control", "No-store ");
Response. setheader ("pramga", "No-catch ");
Response. setdateheader ("expires", 0 );
%>
But it does not work if I use it!
Is it wrong where I put it, or is it a problem?
Sai Yang
Use cache prohibited with Session

The following two posts are for your reference:
[Url] http://bbs.blueidea.com/thread-701496-1-1.html#/url]
[Url] http://bbs.blueidea.com/thread-1556412-1-1.html#/url]
Hope822
Reply #9 sai Yang's post

Now we know we can do this by disabling cache and session.
When I exit, set success to 2.
<C: If test = "$ {success = 2}">
<Div class = "chaoshi">
<H1> you do not have the permission. Please return and log on again! </H1>
<A href = "<% = request. getcontextpath () %>/admin/index. jsp"> return, click here </a>
</Div>
But does the code I used to disable caching not work?
<%
// Disable caching
Response. setheader ("catch-control", "No-store ");
Response. setheader ("pramga", "No-catch ");
Response. setdateheader ("expires", 0 );
%>
The page is displayed after the button is clicked and backed up. The page is displayed only after the button is clicked.
You do not have permission. Please return and log on again!
Why did I make a mistake? Thank you!
Hope822
Please give me some advice again. Here, I 'd like to thank you!
Asp910
Those of you are executed on the server side and are not requested from the server at the backend.
The page may be cached in the Temporary Internet Files directory by the browser.
Clean up cache and Test
In addition, it is best to put the session permission judgment under the filter, and then configure the filtered URL, which facilitates some

 

<% @ 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;
Required parameter Doc ument. All. rownum1.value = O. rowindex;
Too many Doc ument. All. cellnum. value = Window. event. srcelement. parentelement. cellindex;

Window. Open ('simplestaffsearch. js', '', 'scrollbars = Yes, resizable = Yes, width = 600, Height = 450, Left = 50, Top = 100 ');
}

Function checkdata (){
If (check ('c2 ')){
If (document. All. item. value = ""){
Alert ("select the project number! ");
Return false;
}
If (confirm ("the ticket may need to be re-printed. Are you sure you want to modify the Batch project? ")){
Document. All. Refer. value = 'Operation in progress. Please wait ...';
Document. All. Refer. Disabled = true;
Document. theform. Submit ()
}}
Else {
Alert ('select the ticket for Project Information Modification! ')
}
}
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 onkeydown = "shieldkey ()" oncontextmenu = "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"> Project Information Change List </TD> </tr>
<Logic: notpresent name = "resultbilllist" Scope = "request">
<Tr> <TD class = "tipbar3"> no data </TD> </tr>
</Logic: notpresent>
</Table>
<Br/>
<Div style = "display: block;" id = "mydiv">
<Logic: present name = "allsucc" Scope = "request">
<P class = "tipbar3"> the Batch project information has been changed! </P>
</Logic: Present>
<Logic: present name = "succ" Scope = "request">
<P class = "tipbar3"> ticket operation successful! </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 ') "> select all </Th>
<TH nowrap width = "3%"> NO. </Th>
<TH align = "center" width = "15%" nowrap> Application No. </Th>
<TH align = "center" width = "15%" nowrap> official ticket No. </Th>
<TH align = "center" width = "17%" nowrap> time of opening an Application Form </Th>
<TH align = "center" width = "8%" nowrap> applicant </Th>
<TH align = "center" width = "15%" nowrap> Project No. </Th>
<TH align = "center" width = "15%" nowrap> project name </Th>
<TH align = "center" width = "15%" nowrap> project team name </Th>
<TH align = "center" width = "12%" nowrap> total amount </Th>
<TH align = "center" width = "15%" nowrap> ticket status </Th>
</Tr>
<Logic: iterate id = "item" name = "resultbilllist" Scope = "request" indexid = "Index">
<Tr onmouseover = setcol1 (this) onmouseout = 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> Project No.: </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> Project name: </TD>
<TD> <input type = "text" name = "itmename" value = "" size = "40" readonly size = "30"> </TD>
</Tr>
<Tr>
<TD align = "right" nowrap> Project Manager: </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" onfocus = "calendar ()">
<Input type = "button" class = btn1 name = "refer" value = "Batch project change" 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>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.