日期:2014-05-20 浏览次数:20756 次
<!-- TestBeanScope.jsp -->
<%@ page import = "chapter35.Count" %>
<jsp:useBean id = "count" scope = "application" class = "chapter35.Count" />
</jsp:useBean>
<html>
<head>
<title>TestBeanScope</title>
<head>
<body>
<h3>Testing Bean Scope in JSP (Application)</h3>
<% count.increaseCount(); %>
You are visitor number <%= count.getCount() %><br />
From host: <%= request.getRemoteHost() %>
and session: <%= sessiongetId() %>
</body>
</html>
package chapter35;
public class Count
{
private int count = 0;
/** Return count property */
public int getCount()
{
return count;
}
/** Increase count */
public void increaseCount()
{
count++;
}
}