美文网首页
(6) application对象的使用

(6) application对象的使用

作者: 笑笑学生 | 来源:发表于2016-09-09 23:54 被阅读24次

核心代码:
application.jsp

  <body>
    <!-- 显示账号信息 -->
    <%
        String Name = (String)application.getAttribute("user");
        String Password = (String)application.getAttribute("pass");
        out.println("用户名:"+Name);
        out.println("密码:"+Password);
    %>
    
    <br>
    <!--站点计数器  -->
    <%
        String strNum = (String)application.getAttribute("num");
        int num=0;
        if(strNum != null)
            num = Integer.parseInt(strNum)+1;
        application.setAttribute("num", String.valueOf(num));
    %>
    访问次数为:<%=num %>
    
    <%
        out.println("5秒后,自动跳转到cookie计数器界面");
        response.setHeader("Refresh", "5,URL=cookie.jsp");
    %>
  </body>

相关文章

网友评论

      本文标题:(6) application对象的使用

      本文链接:https://www.haomeiwen.com/subject/ajlyettx.html