jsp代码:
<%! int count = 0; %>
<%=(++count)%>

解决方案 »

  1.   

    先建一个javabean程序:
    package test;
    public class Counter
    {
    int Count=1;
    public void Counter()
    {
    }
    public void addCount()
    {
    Count++;
    }
    public int getCount()
    {
    return Count;
    }
    }然后在jsp程序中调用它就行了:
    <%--
    File Name:useCounter.jsp
    Author:fancy
    Date:2001.3.26
    Note:use javabean to say hello world!
    --%>
    <jsp:useBean id="counter" scope="application" class="test.Counter" />
    <br>
    你好你是第
    <%
    out.println(counter.getCount());
    counter.addCount();
    %>位访客