注册 登录
编程论坛 J2EE论坛

老师都搞不懂错在哪.郁闷.希望指点

guoke23 发布于 2006-03-26 13:09, 615 次点击
<%@ page contentType="text/html;charset=GB2312" %>
<HTML>
<BODY>
<%!
synchronized void countPeople()
{
ServletContext application=getServletContext();;

Integer number=(Integer)application.getAttribute("Count");
if (number==null)
{ number=new Integer(1);
application.setAttribute("Count",number);
}
else
{ number=new Integer(number.intValue()+1);
application.setAttribute("Count",number);
}
}
%>
<%
if (session.isNew())
{
countPeople();
Integer myNumber=(Integer)application.getAttribute("Count");
session.setAttribute("MyCount",myNumber);
}
%>
<P><P>您是第
<%int a=((Integer)session.getAttribute("MyCount")).intValue();
%>
<%=a%>
个访问本站的客户。
</BODY>
</HTML>
6 回复
#2
miss_friend2006-03-26 13:56
ServletContext application=getServletContext();;把后面的;去了,我试了没错
#3
〃雙掱ぴ搋兜づ2006-03-27 10:12

能正常显示啊?
有什么毛病吗?

#4
guoke232006-03-27 17:00

去了.就是不能显示...

郁闷~~~~!!

不知道楼上能显示的.是用那个JAVA版本.请问哪里有下载.谢啦.

我Q是:9847571.那位朋友可以帮助的.定感激不尽.

#5
〃雙掱ぴ搋兜づ2006-03-28 09:24
晕。不好使了,
我昨天粘过来还好使。显示“您是第1个访问本站的客户”

但现在一用就不好使了。是HTTP 500错误,错误原因是空指针

我觉得会不会是session的事啊。
你用不同的机器访问。看是不是第一次都好使?
#6
miss_friend2006-03-28 09:42
JAVA1.4呀,可以得,怎么会不成呢,我都有试了的
#7
history_sky2006-03-28 11:51

我觉得你不该在<html>里写函数,我在html里从来没写过函数.

1