教你怎么用JSP統(tǒng)計(jì)網(wǎng)站訪問人數(shù)

統(tǒng)計(jì)訪問人數(shù)1

<%@ page language="java" import="java.util.*" pageencoding="utf-8"%>
<!doctype html public "-//w3c//dtd html 4.01 transitional//en">
<html>
  <head>
    <base href="<%=basepath%>" rel="external nofollow"  rel="external nofollow" >    
<title>my jsp 'sxtcount.jsp' starting page</title>   
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css" rel="external nofollow"  rel="external nofollow" >
	-->
  </head>
  <body>
       <!--聲明式  -->
       <%!
        int  count=0;
       // out.print("您是第"+count+"個(gè)訪問該網(wǎng)站的人");   
       public  void  a(){
       }
       %> 
       <!--小腳本  -->
       <%
  count++; 
  out.print("您是第"+count+"個(gè)訪問該網(wǎng)站的人");
       %>
       <!--表達(dá)式  -->
       <%--  <%=count %> --%>
  </body>
</html>
<!--
總結(jié)
  [1]jsp的本質(zhì)是一個(gè)servlet(就是類)  單實(shí)例多線程的程序
  [2]在jsp頁面中書寫java代碼的方式有3中
     a、小腳本
     b、表達(dá)式
     c、聲明式
  
  [3]小腳本和聲明式的區(qū)別
     a、小腳本中聲明的變量是局部的變量  ,在聲明式中聲明的變量是成員變量
     b、小腳本中不可以定義方法   在聲明式中可以定義方法
     c、在小腳本中可以使用jsp的內(nèi)置對象  在聲明式中不可以使用  
     [4]所有的注釋
      a、java中的注釋     3種
      b、html中注釋
      c、jsp中注釋   
       推薦使用jsp中的注釋
       優(yōu)點(diǎn):節(jié)省網(wǎng)絡(luò)的帶寬,可以增快訪問的速度
 -->

統(tǒng)計(jì)訪問人數(shù)2

<%@ page language="java" import="java.util.*" pageencoding="utf-8"%>
<!doctype html public "-//w3c//dtd html 4.01 transitional//en">
<html>
  <head>
    <base href="<%=basepath%>" rel="external nofollow"  rel="external nofollow" >    
    <title>my jsp 'sxtcount.jsp' starting page</title>
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css" rel="external nofollow"  rel="external nofollow" >
	-->
  </head>  
  <body>
      <!--動(dòng)態(tài)包含 ---動(dòng)作標(biāo)識  -->
      <%--  <jsp:include page="head.jsp"></jsp:include> --%>
      <!--靜態(tài)包含---指令標(biāo)識  -->
      <%@include file="head.jsp" %>
        <div style="height: 400px">
         <!--聲明式  -->
       <%!
        int  count=0;
        %>
       <!--小腳本  -->
       <%
            count++;
            out.print("您是第"+count+"個(gè)訪問該網(wǎng)站的人");
       %>
        </div>       
       <jsp:include page="foot.jsp"></jsp:include>
  </body>
</html>
<!-- 
  動(dòng)態(tài)包含和靜態(tài)包含的區(qū)別:
  [1]靜態(tài)的引入式把代碼原封不動(dòng)的復(fù)制到主文件中,動(dòng)態(tài)的引入是相當(dāng)于方法的調(diào)用  
  [2]靜態(tài)的引入的方式引入文件和主文件中是不可以存在同名的變量 ,動(dòng)態(tài)的引入可以存在
  [3]靜態(tài)的引入式不會產(chǎn)生class文件   ,動(dòng)態(tài)的引入式產(chǎn)生class文件
  [4]靜態(tài)的引入產(chǎn)生的時(shí)機(jī)是第一個(gè)階段  ,動(dòng)態(tài)的引入式產(chǎn)生產(chǎn)生的時(shí)機(jī)是第三階段
 共同點(diǎn):
  都可以實(shí)現(xiàn)網(wǎng)頁的引入 -->

總結(jié)

在這里插入圖片描述

到此這篇關(guān)于教你怎么用jsp統(tǒng)計(jì)網(wǎng)站訪問人數(shù)的文章就介紹到這了,更多相關(guān)jsp統(tǒng)計(jì)網(wǎng)站訪問人數(shù)內(nèi)容請搜索碩編程以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持碩編程!

相關(guān)文章
亚洲国产精品第一区二区,久久免费视频77,99V久久综合狠狠综合久久,国产免费久久九九免费视频