application、session和request的計數器

session計數器:

    <%
    Integer counter=(Integer)session.getAttribute("counter");
    if(counter==null){
    	counter=1;
    }else{
    	counter++;
    }
    
    session.setAttribute("counter", counter);
    String realpath=application.getRealPath("/");
    String counter = session.getId();</span>
     %>
     當前頁面初訪問的次數:<%=counter %><br>
     SessionID:<%=counter %>

application計數器:

    <%
    Integer counter=(Integer)application.getAttribute("counter");
    if(counter==null){
    	counter=1;
    }else{
    	counter++;
    }
    
    application.setAttribute("counter", counter);
    String realpath = application.getRealPath("/");
     %>
     當前頁面初訪問的次數:<%=counter %>


發佈了32 篇原創文章 · 獲贊 17 · 訪問量 20萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章