jsp计数器-jsp文件
程序员文章站
2024-02-26 12:06:22
<html>
<head>
<title>jsp bean example</title>
</head>
<body>
<!-- set the scripting language to java -->
<%@ page language="java" %>
<!-- instantiate the counter bean with an id of "counter" -->
<jsp:usebean id="counter" scope="session" class="counter" />
<!-- set the bean's count property to the value of -->
<!-- the request parameter "count", using the -->
<!-- jsp:setproperty action. -->
<jsp:setproperty name="counter" property="count" param="count" />
<%
// write the current value of the property count
out.println("count from scriptlet code : "
+ counter.getcount() + "<br>");
%>
<!-- get the bean's count property, -->
<!-- using the jsp:getproperty action. -->
count from jsp:getproperty :
<jsp:getproperty name="counter" property="count" /><br>
</body>
</html>
<head>
<title>jsp bean example</title>
</head>
<body>
<!-- set the scripting language to java -->
<%@ page language="java" %>
<!-- instantiate the counter bean with an id of "counter" -->
<jsp:usebean id="counter" scope="session" class="counter" />
<!-- set the bean's count property to the value of -->
<!-- the request parameter "count", using the -->
<!-- jsp:setproperty action. -->
<jsp:setproperty name="counter" property="count" param="count" />
<%
// write the current value of the property count
out.println("count from scriptlet code : "
+ counter.getcount() + "<br>");
%>
<!-- get the bean's count property, -->
<!-- using the jsp:getproperty action. -->
count from jsp:getproperty :
<jsp:getproperty name="counter" property="count" /><br>
</body>
</html>