jsp下载链接的统计及返回!!!求助!!!
mylink.jsp有一个, "下载 "连接,现在我想他的点击次数,想法是在数据库中建一个T表,有个字段为T_DownTime,初始值为0,只要点击 "下载 "一次,T_DownTime字段的值就加1,已经可以对下载连接的点击进行统计了,方法是:
我把 "下载 "连接写成 <a href= "count.jsp?pid= <=pid> "> ,在count.jsp页面完成了数据库操作,增一更新T_DownTime字段,
我的下载文件放在jsp文件同目录的upload文件夹内,下载地址为:http://127.0.0.1/my/upload/123(XXX).jpg(假如下载的是123.jpg)
可是不知道如何重定想到文件下载连接:http://127.0.0.1/my/upload/123.jpg(假设pid此时为 "123 ",实际中不能确定),请各位大侠在帮帮我呀,谢谢了.
mylink.jsp
<%@ page language= "java " contentType= "text/html; charset=gb2312 " %>
<%@ include file= "inc.jsp "%>
<%
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();
%>
...
<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 "> [
<a href= "count.jsp?Pid= <%=Pid%> ">
<%count=Integer.parseInt(sqlRst.getString( "T_DownTime "));count++;%> 下 载 </a> ][ <a href= "javascript:window.close(); "> 关 闭 </a> ] </div> </td>
</tr>
<tr>
...
count.jsp
<%@ include file= "inc.jsp "%>
<%
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 sqlRst=mySearch.getResult();
sqlRst.first();
sqlRst.previous();
if(sqlRst.next())
{
String sql1= "update T_P set T_DownTime=T_DownTime+1 where T_Code = "+Pid+ " ";
myBean myUpdate = new operateDBBean();
myUpdate.setConnection();
myUpdate.setQuerystatement(sql1);