日期:2014-05-16 浏览次数:20331 次
package beans public class Counter(){ private long counter; public long getCounter(){ return counter; } public void setCounter(long counter){ this.counter=counter+1; } }
<%@ page import="java.util.*" language="java" contentType="text/html;charSet="gb18030"%> <jsp:useBean id="counter" class="beans.Counter" scope="application"></jsp:useBean> <html> <head> <title>JavaBean计数器</title> </head> <body> <% if(session.isnew) { long temp=counter.getCounter(); counter.setCounter(temp); } %> <font size="2"> JavaBean实现的计数器: 您是第 <jsp:getProperty name="counter" property="counter"/>位访问网站; </font> </body> </html>