计数1

news/2024/7/4 0:53:10 标签: string, user, sql, import, class, insert
class="baidu_pl">
class="article_content clearfix">
class="htmledit_views">

String ip=request.getRemoteAddr();

获取用户ip

记录新用户

<jsp:useBean id="mycount" class="com.pp.db.CountOnline "></jsp:useBean> <%
     String ip=request.getRemoteAddr();
    
    
     //获得用户ip地址
     mycount.setUserip(ip);
     ResultSet rs=mycount.checkclass="tags" href="/tags/USER.html" title=user>user();
     rs.last();
     int num=rs.getRow();
   %>
   <table>
  
    <tr bgcolor="lightgrey">
     <td>
      访问者ip地址
     </td>
       <td>
       访问次数
     </td>
   
    </tr>  
    <%
     rs.beforeFirst();
     while(rs.next()){
     %>
   
     <tr>
     <td>
       <%=rs.getString("class="tags" href="/tags/USER.html" title=user>user_ip") %>
     </td>
      <td>
     <%=rs.getInt("class="tags" href="/tags/USER.html" title=user>user_times") %>
     </td>
   
    </tr>  
  
   <%} %>
   <tr>
    <td colspan="2">
       你的ip为:<%=ip %>
       <br>
       你的访问次数为:<%=mycount.getTimes() %>次
       共有<%=num %>个新用户访问过本页
     </td>
  
   </tr>
   </table>


    package com.pp.db;
class="tags" href="/tags/IMPORT.html" title=import>import java.class="tags" href="/tags/SQL.html" title=sql>sql.*;
class="tags" href="/tags/IMPORT.html" title=import>import java.class="tags" href="/tags/SQL.html" title=sql>sql.SQLException;


public class CountOnline {
 
 private String class="tags" href="/tags/USER.html" title=user>userip;
 private String nowdate;
 private int times;
 private DBOperation db=new DBOperation();
 public CountOnline()
 {}
 public ResultSet checkclass="tags" href="/tags/USER.html" title=user>user(){
  ResultSet rs=null;
  String class="tags" href="/tags/SQL.html" title=sql>sql="select * from class="tags" href="/tags/USER.html" title=user>usercount where class="tags" href="/tags/USER.html" title=user>user_ip='"+this.class="tags" href="/tags/USER.html" title=user>userip+"'";
 
  try {
   rs=  db.executeQuery(class="tags" href="/tags/SQL.html" title=sql>sql);
   if(rs.next())
   {
    this.times=rs.getInt("class="tags" href="/tags/USER.html" title=user>user_times")+1;
    class="tags" href="/tags/SQL.html" title=sql>sql="update class="tags" href="/tags/USER.html" title=user>usercount set class="tags" href="/tags/USER.html" title=user>user_times="+this.times+" where class="tags" href="/tags/USER.html" title=user>user_ip='"+this.class="tags" href="/tags/USER.html" title=user>userip+"'";
    db.executeUpdate(class="tags" href="/tags/SQL.html" title=sql>sql);
   }
   
   else
   {
    this.times=1;
    class="tags" href="/tags/SQL.html" title=sql>sql="insert into class="tags" href="/tags/USER.html" title=user>usercount(class="tags" href="/tags/USER.html" title=user>user_ip,class="tags" href="/tags/USER.html" title=user>user_times) values('"+this.class="tags" href="/tags/USER.html" title=user>userip+"',1)";
    db.executeUpdate(class="tags" href="/tags/SQL.html" title=sql>sql);
   }
   rs=db.executeQuery("select * from class="tags" href="/tags/USER.html" title=user>usercount");
   
   
  } catch (SQLException e) {
   // TODO 自动生成 catch 块
   e.printStackTrace();
  }
  
  
  return rs;
  
 }

 
 public void dbclose()
 {
  db.closeConnection();
  
 }
 public String getNowdate() {
  return nowdate;
 }
 public void setNowdate(String nowdate) {
  this.nowdate = nowdate;
 }
 public int getTimes() {
  return times;
 }
 public void setTimes(int times) {
  this.times = times;
 }
 public String getUserip() {
  return class="tags" href="/tags/USER.html" title=user>userip;
 }
 public void setUserip(String class="tags" href="/tags/USER.html" title=user>userip) {
  this.class="tags" href="/tags/USER.html" title=user>userip = class="tags" href="/tags/USER.html" title=user>userip;
 }

}

String ip=request.getRemoteAddr();

获取用户ip

记录新用户

<jsp:useBean id="mycount" class="com.pp.db.CountOnline "></jsp:useBean> <%
     String ip=request.getRemoteAddr();
    
    
     //获得用户ip地址
     mycount.setUserip(ip);
     ResultSet rs=mycount.checkclass="tags" href="/tags/USER.html" title=user>user();
     rs.last();
     int num=rs.getRow();
   %>
   <table>
  
    <tr bgcolor="lightgrey">
     <td>
      访问者ip地址
     </td>
       <td>
       访问次数
     </td>
   
    </tr>  
    <%
     rs.beforeFirst();
     while(rs.next()){
     %>
   
     <tr>
     <td>
       <%=rs.getString("class="tags" href="/tags/USER.html" title=user>user_ip") %>
     </td>
      <td>
     <%=rs.getInt("class="tags" href="/tags/USER.html" title=user>user_times") %>
     </td>
   
    </tr>  
  
   <%} %>
   <tr>
    <td colspan="2">
       你的ip为:<%=ip %>
       <br>
       你的访问次数为:<%=mycount.getTimes() %>次
       共有<%=num %>个新用户访问过本页//用一个ip来算一个计数,用此num来表示
     </td>
  
   </tr>
   </table>


    package com.pp.db;
class="tags" href="/tags/IMPORT.html" title=import>import java.class="tags" href="/tags/SQL.html" title=sql>sql.*;
class="tags" href="/tags/IMPORT.html" title=import>import java.class="tags" href="/tags/SQL.html" title=sql>sql.SQLException;


public class CountOnline {
 
 private String class="tags" href="/tags/USER.html" title=user>userip;
 private String nowdate;
 private int times;
 private DBOperation db=new DBOperation();
 public CountOnline()
 {}
 public ResultSet checkclass="tags" href="/tags/USER.html" title=user>user(){
  ResultSet rs=null;
  String class="tags" href="/tags/SQL.html" title=sql>sql="select * from class="tags" href="/tags/USER.html" title=user>usercount where class="tags" href="/tags/USER.html" title=user>user_ip='"+this.class="tags" href="/tags/USER.html" title=user>userip+"'";
 
  try {
   rs=  db.executeQuery(class="tags" href="/tags/SQL.html" title=sql>sql);
   if(rs.next())
   {
    this.times=rs.getInt("class="tags" href="/tags/USER.html" title=user>user_times")+1;
    class="tags" href="/tags/SQL.html" title=sql>sql="update class="tags" href="/tags/USER.html" title=user>usercount set class="tags" href="/tags/USER.html" title=user>user_times="+this.times+" where class="tags" href="/tags/USER.html" title=user>user_ip='"+this.class="tags" href="/tags/USER.html" title=user>userip+"'";
    db.executeUpdate(class="tags" href="/tags/SQL.html" title=sql>sql);
   }
   
   else
   {
    this.times=1;
    class="tags" href="/tags/SQL.html" title=sql>sql="insert into class="tags" href="/tags/USER.html" title=user>usercount(class="tags" href="/tags/USER.html" title=user>user_ip,class="tags" href="/tags/USER.html" title=user>user_times) values('"+this.class="tags" href="/tags/USER.html" title=user>userip+"',1)";
    db.executeUpdate(class="tags" href="/tags/SQL.html" title=sql>sql);
   }
   rs=db.executeQuery("select * from class="tags" href="/tags/USER.html" title=user>usercount");
   
   
  } catch (SQLException e) {
   // TODO 自动生成 catch 块
   e.printStackTrace();
  }
  
  
  return rs;
  
 }

 
 public void dbclose()
 {
  db.closeConnection();
  
 }
 public String getNowdate() {
  return nowdate;
 }
 public void setNowdate(String nowdate) {
  this.nowdate = nowdate;
 }
 public int getTimes() {
  return times;
 }
 public void setTimes(int times) {
  this.times = times;
 }
 public String getUserip() {
  return class="tags" href="/tags/USER.html" title=user>userip;
 }
 public void setUserip(String class="tags" href="/tags/USER.html" title=user>userip) {
  this.class="tags" href="/tags/USER.html" title=user>userip = class="tags" href="/tags/USER.html" title=user>userip;
 }

}


http://www.niftyadmin.cn/n/1426154.html

相关文章

pv promotion video

pvPromotion Video&#xff08;有人说和我们所说的MV是一回事&#xff0c;其实不然&#xff0c;看名字就知道啦&#xff0c;是宣传推广用的VIDEO&#xff0c;大家也应该注意到了PV都是在单曲推出前10天左右就在电视上有播了&#xff0c;就是为了宣传即将到来的新单曲&#xff0…

JSP在线统计 源码 未研究

http://d.download.csdn.net/down/244777/wumaolin jsporacle

window.open参数一览

<script type"text/javascript">function StorePage(){ddocument;td.selection?(d.selection.type!None?d.selection.createRange().text:):(d.getSelection?d.getSelection():);void(keyitwindow.open(http://www.365key.com/storeit.aspx?tescape(d.titl…

使用弹窗代码生成器及各类弹窗浮动广告code

http://tool.admin5.com/tools/OpenWindows.html 弹窗代码生成器 http://top.admin5.com/daima/ 各类广告代码 (文字滚动消息广告两个焦点代码(就是像迅雷左上角的几组换图的广告一样) 影院模式幻灯广告(同焦点一样的) 10款JS广告代码 广告http://www.haofa.net/…

媒体查询简单应用——网页字体自适应窗口大小

什么是媒体查询&#xff1f; 答&#xff1a;媒体查询是向不同设备&#xff08;手机&#xff0c;平板&#xff0c;电脑&#xff09;提供不同样式的一种不错方式&#xff0c;它为每种类型的用户提供了最佳的体验。 举一个简单的例子&#xff1a;网页的字体大小随窗口的大小而改…

只对新用户计数

只对新用户计数表结构 tb_newusercount 字段user_id,user_ip,user_timesDB类package com.count.Online; import java.sql.*; public class DB { private Connection con; private Statement stm; private ResultSet rs; private String classname"com.micro…

!important、3种级联样式、选择器优先级 详细介绍

1、!important 表示最高优先级&#xff08;ie6浏览器不认识 !important &#xff09;。 例如: 正常情况下&#xff0c;写在下面的样式优先级高于上面的样式 demo1{ color:red; color:green; /*绿色的优先级高于红色&#xff0c;所有浏览器都会显示绿色*/ } 加了!important 那么…