The research of JSP duplicate submission

Source: Internet
Author: User
JSP summary of issues in which pages cannot be refreshed or prevented from refreshing<1> If you want the form to refresh when you select, delete, modify, and so on, you need to add: window.returnvalue=0. such as leadership/leader_ctl.jsp
< body LeftMargin = "0" topmargin = "0" > <%@ page contentType = "text/html;         charset=gb2312 "language =" java "import =" java.sql.* "ErrorPage =" "%> <%@ page import =" leader.* "%> <% Leaderbean leader=NewLeaderbean ();     String struserid=request.getparameter ("Key");     Session.setattribute ("Employuserid", strUserID); System.out.println ("strUserID:" +struserid);if(leader.        Postedit (Request)) {//system.out.println ("me5"); Out.println ("<script>window.returnvalue=0;window.close ();</script>"); return; }Else{if(Request.getparameter ("Oper")!=NULL){if(Request.getparameter ("Oper"). Equals ("Delleader")) {out.println ("<script>alert" +leader).             lastopermsg+ "');window.returnvalue=0;</script>");         Return }if(Request.getparameter ("Oper"). Equals ("Setleader"))              {//system.out.println ("Me3"); Out.println ("<script>alert" ("+leader").             lastopermsg+ "'); Window.returnvalue=0;window.close ();</script>");             System.out.println ("Me4");         Return }if(Request.getparameter ("Oper"). Equals ("Delcompetence"))              {////system.out.println ("strUserID:" +struserid); Out.println ("<script>alert" ("+leader").             lastopermsg+ "'); History.back ();</script>");             System.out.println ("Me4");         Return }if(Request.getparameter ("Oper"). Equals ("Addcompetence"))              {//system.out.println ("AddCompetence1"); Out.println ("<script>alert" ("+leader").             lastopermsg+ "'); History.back ();</script>");             System.out.println ("AddCompetence2");         Return }Else{if(Request.getparameter ("Oper"). Equals ("QX")) {out.println ("<script>alert" +leader).               lastopermsg+ "'); Window.returnvalue=0;window.close ();</script>");            Return }Else{//system.out.println ("Me6"); Out.println ("<script>alert" ("+leader").                lastopermsg+ "'); Window.close ();</script>");            Return }//3e}}}%>
<2> If you require automatic refresh from the server at intervals, add: (1) Method: <%response.setheader ("Refresh", "");%>
15 Wonderful Refresh once (2) method: automatically refresh Web pages
By adding the following code to and from the HTML, the page that you are browsing after 5 minutes will automatically change to target.html. The delay time, in seconds, for the refresh of 300 in the code. Targer.html for the target page you want to turn to, if this page is the automatic refresh this page. <meta http-equiv= "Refresh" content= "300; Url=target.html "> (3) Method: Demo Effect: This page will automatically refresh at the specified time, code hint: Copy the following code to the 〈head〉 area
<script> <!--var limit= "0:15"//Modify Refresh time if (document.images) {var parselimit=limit.split (":") parselimit=parse LIMIT[0]*60+PARSELIMIT[1]*1} function Beginrefresh () {if (!document.images) return if (parselimit==1) Window.location.reload () else{parselimit-=1 Curmin=math.floor (PARSELIMIT/60) cursec=parselimit%60 if (curmin!=0) curtime=curmin+ "+cursec+" seconds and then brush the page again. "Else curtime=cursec+" seconds to brush this page again. "Window.status=curtime settimeout (" Beginrefresh () ", 1000)} Window.onload=beginrefresh//--> </script>
<2> to prevent automatic refresh from the server, you need to add:
<%@ page contenttype= "text/html;charset=gb2312"%><%@ page language= "java" import= "java.io.*"%>< Html>
Programme 2
J J SP counter, the same computer 10 seconds to prevent refreshing<%@ page contenttype= "text/html; charset=gb2312 "language=" java "import=" java.sql.* "errorpage=" "%>"
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<meta name= "generator" http-equiv= "Refresh" >
<title> Untitled Document </title>
<link href= "Css/counter.css" rel= "stylesheet" type= "Text/css" >
<body bgcolor= "#FFFFFF" >
<!--start counter-->
<div align= "center" >
<%@ page import= "Com.ckj.counter.*,java.io.*,java.util.date"%>
<%counter ct=new Counter ();
String count= "0";
String counterid= "0";
try{
String Strdirpath = new File (Application.getrealpath (Request.getrequesturi ()). GetParent ();
System.out.println ("The absolute path of the directory:" + Strdirpath + "<br/>");
String strFullPath = Session.getservletcontext (). Getrealpath ("/");
System.out.println (strFullPath);
ct.path=strfullpath+ "/counter/count.txt";
1 Session Store time value,
2 Next time Compare
if (Session.getattribute ("Counttime") ==null) {//if the initial visit
Count=ct.docount ();
SYSTEM.OUT.PRINTLN ("--------calculation--------" +system.currenttimemillis ());
Session.setattribute ("Counttime", String.valueof (System.currenttimemillis ()));}
Else
{//If the refresh interval exceeds
System.out.println ("--------Refresh Difference--------" + (System.currenttimemillis ()-L
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.