- <%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"
- isErrorPage="true" errorPage="error.jsp" isThreadSafe="true" session="true"
- buffer="8kb" autoFlush="true" info="..." %>
- <% String path=r equest.getContextPath(); String basePath=r equest.getScheme()+
- "://"+request.getServerName()+ ":"+request.getServerPort()+path+ "/"; %>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <base href="<%=basePath%>">
- <title>
- My JSP 'index.jsp' starting page
- </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>
- <%! int count=0;//使用JSP声明的变量(成为全局变量,而且还是静态变量) %>
- <% int count1=0;//使用JSP表达式定义的变量(非静态变量)每次访问都会初始化,每次访问相互独立 %>
- <%count++; count1++; %>
- <h1>
- count:
- <%=count%>
- </h1>
- <h1>
- count1:
- <%=count1 %>
- </h1>
- </body>
- </html>
来源: http://www.bubuko.com/infodetail-1947082.html