⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usercounter.jsp

📁 精通从JavaScript到Jsp范例程序设计
💻 JSP
字号:
<%@ page language="java" isThreadSafe="true" %>
<%@ page import="java.util.*"  %>
<%@ page import="java.text.*"  %>
<%! 
	Hashtable userTable = new Hashtable(); 
	int totalCount=0;	
	
	public String getNowDate(){
		SimpleDateFormat formatter = 
		    new SimpleDateFormat ( "yyyy/MM/dd a hh:mm:ss", Locale.US );
      		Date currentTime = new Date();
		return formatter.format(currentTime);
	}
				
  public int getCount( String userName ){
    Integer count = (Integer)userTable.get( userName );
    if( count != null ){ 
      int nowCount = count.intValue() + 1;
      userTable.put( userName, new Integer( nowCount ) ); 
      return nowCount;
    }		
    userTable.put( userName, new Integer( 1 ) );
    return 1;
  }
    	
  public void delay( long millis ){
  	try{
  		Thread.sleep( millis );
  	}
  	catch( InterruptedException intex ){
  	}	
  }      
%>
<% 
	String username = request.getParameter( "textUserName" );
	int count = getCount( username );
	int localTotalCount;
	synchronized( this ){
		localTotalCount = ++totalCount;
	}
%>
<html>
<head>
<title>Login Counter</title>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
</head>
<body bgcolor="#FFFFFF">
<div align="center"> 
  <p><font color="#0000FF">瞷

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -