我想把计数器的数字显示改成图形的,应该怎么改呢?
就是有1.jpg,2.jpg,3.jpg...对应数字1,2,3...怎么用在jsp页面里?
应该是怎样的语句?
还有,怎么在页面里显示客户机的IP呢?
<%@ page contentType="text/html;charset=GB2312" %> <%@ page import="java.io.*" %> <HTML> <BODY> <%! int number=0; synchronized void countPeople() { if(number==0) { try{File f=new File("D:/tomcat","countPeople.txt"); FileInputStream in=new FileInputStream(f); DataInputStream dataIn=new DataInputStream(in); number=dataIn.readInt(); number++; in.close();dataIn.close(); } catch(FileNotFoundException e) { number++; try {File f=new File("D:/tomcat","countPeople.txt"); FileOutputStream out=new FileOutputStream(f); DataOutputStream dataOut=new DataOutputStream(out); dataOut.writeInt(number); out.close();dataOut.close(); } catch(IOException ee){} } catch(IOException ee) { } } else {number++; try{File f=new File("D:/tomcat","countPeople.txt"); FileOutputStream out=new FileOutputStream(f); DataOutputStream dataOut=new DataOutputStream(out); dataOut.writeInt(number); out.close();dataOut.close(); } catch(FileNotFoundException e){} catch(IOException e){} } } %> <% if(session.isNew()) {countPeople(); String str=String.valueOf(number); session.setAttribute("count",str); } %> <P>您是第<%=(String)session.getAttribute("count")%>个访问本站的人。 <BODY> <HTML>