当前位置:编程学习 > JSP >>

大家帮我做一道JSP题。我要看完整版能运行的代码。。。

编写一个JSP页面,,统计该网页被访问的次数。。。(用户没打开一次窗口运行该网页,或在同一窗口刷新该网页都算运行一次,可利用application对象去实现。。。)
答案:<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>
其他://EN 每次加一就行了 

上一个:请教一个jsp连接数据库的代码的含义
下一个:jsp 怎么从后台获取到 可编辑下拉列表框的值啊? 前台是可编辑的下拉列表框。有代码打把前台后台代码写上

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,