<iframe        
 frameborder=20 height=22 scrolling=no src="count.jsp"  width=120 topmargin="0" leftmargin="0" target="_self">                 
</iframe>建立一個hits.txt文件,初始化為1,並找0~9十個數字的圖片.全部放在同一個目錄下.count.jsp*****
<%@ page contentType="text/html;charset=big5"%>
<%@ page language="java" import="java.io.*"%>
<%@ page import="java.lang.*"%><%
String szPath=application.getRealPath("/");
szPath=szPath+"hits.txt";
String szRecord="";
BufferedReader file=new BufferedReader(new FileReader(szPath));
try{
    szRecord=file.readLine();
}
catch(IOException e){
    System.out.println("讀計數器數據錯誤");
}
if(szRecord==null)  szRecord="0";int nRecord=0;
nRecord=java.lang.Integer.parseInt(szRecord)+1;
//System.out.println(nRecord);
try{
    File f=new File(szPath);
    PrintWriter pw=new PrintWriter(new FileWriter(f));
    pw.print(nRecord);
    pw.close();
}
catch(IOException e){
    System.out.println("寫計數器數據錯誤");
}
String szOut="<body topmargin='0' leftmargin='0' bgcolor='#000000'>";
int i=0;
int k=8-szRecord.length();
for (i=0;i<k-1;i++)szOut=szOut + "<img src='0.gif'>";
for (i=0;i<szRecord.length();i++){
    szOut=szOut+"<img src='" + szRecord.charAt(i) +".gif'>";
}
szOut=szOut+"</body>";
out.println(szOut);
%>