Just a preliminary understanding of the JSP nine objects, such as the ASP simple page program to find data written out should be no problem, but there is a problem has been puzzling me, that is how to deploy JavaBean? In the afternoon to see the tutor, look for information this evening to study a clear, the following simple program although can record the number of visits , but application reboot and restore zero, so also add a data storage function, or forget it, practice practicing, are similar.
<%@ page contenttype= "text/html; charset=gb2312 "%>
<%@ page import= "java.util.*"%>
<%
JSP Example
Simple Counter
Code by Xmaro
%>
<HTML>
<pre>
<%
Integer asum= (integer) application.getattribute ("Sum");
Integer ssum= (integer) session.getattribute ("Sum");
if (asum==null) {
asum=0;
}
if (ssum==null) {
ssum=0;
}
Application.setattribute ("Sum", asum+1);
Session.setattribute ("Sum", ssum+1);
Asum= (Integer) application.getattribute ("Sum");
Ssum= (Integer) session.getattribute ("Sum");
%>
<HR width=62% border=1 align=left><br>
You have visited the number of times is: <%=sSum%> The total amount of visits to the page: <%=aSum%>
</pre>
</BODY></HTML>
Just a preliminary understanding of the JSP nine objects, such as the ASP simple page program to find data written out should be no problem, but there is a problem has been puzzling me, that is how to deploy JavaBean? In the afternoon to see the tutor, look for information this evening to study a clear, the following simple program although can record the number of visits , but application reboot and restore zero, so also add a data storage function, or forget it, practice practicing, are similar.
<%@ page contenttype= "text/html; charset=gb2312 "%>
<%@ page import= "java.util.*"%>
<%
JSP Example
Simple Counter
Code by Xmaro
%>
<HTML>
<pre>
<%
Integer asum= (integer) application.getattribute ("Sum");
Integer ssum= (integer) session.getattribute ("Sum");
if (asum==null) {
asum=0;
}
if (ssum==null) {
ssum=0;
}
Application.setattribute ("Sum", asum+1);
Session.setattribute ("Sum", ssum+1);
Asum= (Integer) application.getattribute ("Sum");
Ssum= (Integer) session.getattribute ("Sum");
%>
<HR width=62% border=1 align=left><br>
You have visited the number of times is: <%=sSum%> The total amount of visits to the page: <%=aSum%>
</pre>
</BODY></HTML>
The first time on December 28, 2005 3:01 pm published in Donews blog, because Donews blog no longer updated, special forwarding on this.