日期:2014-05-18  浏览次数:20691 次

jsp文件下载统计问题,请各位大侠指点了@@@
my.jsp

<%@   page   language= "java "   contentType= "text/html;   charset=gb2312 "   %>
<%@   include   file= "a.jsp "%>
<%       int   count=0;
          String     PId=request.getParameter( "PId ");
          String   sql= "select   *   from   T_P   where   T_Code   =   "+PId+ " ";
                    myBean   mySearch   =   new   myBean();
  mySearch.setConnection();
  mySearch.setQuerystatement(sql);
  ResultSet   myRst=mySearch.getResult();
  myRst.first();  
  myRst.previous();
%>


...  
<td   height= "32 "> </td>
<OBJECT     classid= "CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 "     height=0     id=wb     name=wb     width=0> </OBJECT>            
<td   colspan= "4 "> <div   align= "center ">
[   <%out.print( " <a   href= 'upload/ ");%>
<%=   myRst.getString( "T_Name ")   %>
<%out.print( " '   onclick= 'wb.execwb(4,9) '> ");   %> 下   载 </a> ]
[   <a   href= "javascript:window.close(); "> 关   闭 </a>   ] </div> </td>
...
现在我想统计,简单的,就是统计 "下载 "的点击次数,想法是在数据库中建一个T表,有个字段为downcount,初始值为0,每次在下载页面获得该字段值赋给变量count,只要点击 "下载 "一次,count就加1,然后更新该字段,可我是初学者不知道在我上述部分代码如何检测点击 "下载 "事件,然后使count++;是用javascript还是java,该怎么着手呢?
...
<tr>
<td   height= "32 "> </td>
<OBJECT     classid= "CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 "     height=0     id=wb     name=wb     width=0> </OBJECT>            
<td   colspan= "4 "> <div   align= "center "> [  
<%out.print( " <a   href= 'upload/ ");%>
<%=   sqlRst.getString( "T_Name ")   %>  
<%out.print( " '   onclick= 'wb.execwb(4,9) '> ");   %>
<%count=Integer.parseInt(sqlRst.getString( "T_DownTime "));count++;%> 下   载 </a> ][   <a   href= "javascript:window.close(); "> 关   闭 </a>   ] </div> </td>
  </tr>

<tr>  
<%try{
                String   sql1= "update   T_P   set   T_DownTime= "+count+ "   where   T_Code   =   "+PId+ " ";
                                    myBean   myUpdate   =   new   myBean();
myUpdate.setConnection();
myUpdate.setQuerystatement(sql1);
myUpdate.updateRecord();
}
catch(Exception   e){
out.println(e.getMessage());
}%>
...
以上是初步想法,可是数据表字段只要是该页面加载就自增,根本不用点 "下载 "的超链接.我想要点 "下载 "后才统计,请问有办法解决吗,恳求各位指点了...

------解决方案---------