zoukankan      html  css  js  c++  java
  • JSP复习(part 4)

    3.5.2 重定向网页

            使用response对象中的sendRedirect()方法实现一个重定向到另一个页面。

                          例如: response.sendRedirect(“”login_ok.jsp“”);

    3.5.3页面定时刷新或自动跳转

            采用response对象的setHeader方法,实现页面的定时跳转或定时自刷新。

                 (1)response.setHeader("refresh","5");//每隔五秒,页面自动刷新一次

                 (2)response.setHeader("refresh","10;URL=http:www.sohu.com“');

    代码练习

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%
     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>response内置对象</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>
      <%
      //使用response对象的setHeader方法设置为每隔一秒刷新一次页面
      response.setHeader("refresh","1");
      //获取当前时间
      Date myDate = new Date();
       %>
       <h3>当前时间为:</h3>
       <%
       //将当前时间进行显示
       out.println(myDate.toLocaleString());
        %>
     </body>
    </html>

  • 相关阅读:
    BZOJ1036 [ZJOI2008]树的统计Count
    3224: Tyvj 1728 普通平衡树
    BZOJ 3343教主的魔法
    BZOJ 2002[Hnoi2010]Bounce 弹飞绵羊
    BZOJ1503 [NOI2004]郁闷的出纳员
    BZOJ1588 [HNOI2002]营业额统计
    带有上下界的网络流
    堆优化 dijkstra +路径输出
    luogu P3388 【模板】割点(割顶)
    Tarjan 算法求无向图的割顶和桥
  • 原文地址:https://www.cnblogs.com/frankzone/p/7622114.html
Copyright © 2011-2022 走看看