usercounter.jsp
来自「大量jsp编程使用例子」· JSP 代码 · 共 40 行
JSP
40 行
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page language="java" %>
<%@ page import="java.util.*;" %>
<%!
Hashtable userTable = new Hashtable();
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;
}
%>
<%
String username = request.getParameter( "textUserName" );
int count = getCount( username );
%>
<html>
<head>
<title>指定用户计数器</title>
</head>
<body>
<CENTER>
<FONT SIZE=5 COLOR=BLUE>指定用户计数器</FONT>
</CENTER>
<BR>
<HR>
<BR>
<div align="center">您好!
<font color="#3333FF"><b><%= username %></b></font>
您已经到本站参观了
<font color="#3333FF"><b><%= count %></b></font> 次</div>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?