(1) 使用绿色版本JDK,解压到一个目录上D:\jdk1.6。
   (2) 使用绿色版本Tomcat,解压到另一个目录上D:\jdk1.6\tomcat5.5

只要在bat文件D:\tomcat5.5\bin\catalina.bat,
    配置JAVA_HOME就可运行了。
    增加:set JAVA_HOME="D:\jdk1.6",这样就可以运行了。

测试tomcat,访问:  http://127.0.0.1:8080/,能打开访问的页面即可.

用一个简单的投票系统。http://127.0.0.1:8080/vote/
投票系统(请不要下载,已经加密)

其中,有一个管理界面的mainform.jsp上有一个按钮,修改数据,所链接的是isvisable.jsp, 点击修改后,又返回mainform.jsp.
问题是: 不能刷新mainform.jsp,它还是显示原来的数据.

故我用了一个简单的解决方案:
         在mainform.jsp上,禁止缓存,
如下:
<%response.setHeader("Cache-Control","no-store");%>
<%response.setHeader("Pragma","no-cache");%>
<%response.setDateHeader("Expires",0);%>

<head>
<META   HTTP-EQUIV="pragma"   CONTENT="no-cache">   
<META   HTTP-EQUIV="Cache-Control"   CONTENT="no-cache,   must-revalidate">   
<META   HTTP-EQUIV="expires"   CONTENT="Mon,   23   Jan   1978   20:52:30   GMT">  
</head>

在isvisable.jsp中,

<%
 int questionid;
 int isvisable;
 questionid = Integer.parseInt(request.getParameter("questionid"));
 out.print(questionid);
 sql = "SELECT IsVisable from Questions where QuestionID ="+questionid;
 rs = smt.executeQuery(sql);
 out.println(rs);

while(rs.next())
  {
   isvisable = rs.getInt(1);
   out.println(isvisable);
   if(isvisable==1)
   {
     Statement smttmp   =   con.createStatement(); 
     sql = "update Questions set IsVisable = 0 ,IsOpen = 0 ,IsOpenDetial = 0 where QuestionID = "+questionid;
     smttmp.executeUpdate(sql);
     //response.sendRedirect("mainform.jsp"); //去掉,不能直接返回,因更新数据库,需要时间
   }
   else if(isvisable==0)
   {
     Statement smttmp   =   con.createStatement(); 
     sql = "update Questions set IsVisable = 1 ,IsOpen = 0 ,IsOpenDetial = 0 where QuestionID = "+questionid;
     smttmp.executeUpdate(sql);
     //response.sendRedirect("mainform.jsp"); //去掉,不能直接返回,因更新数据库,需要时间.
   }

}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312"> 
<meta http-equiv="Refresh" content="1;url= mainform.jsp"> //等待1秒后,自动刷新到主页面.
<title>
isvisable
</title>
</head>

</html>

有没有好的方法呢?

原来只要正常的关闭连接就可以了,感觉是不是这样就提交了,特别是要关闭connection,
问题解决了,看来还是要根据规范编写程序才行,打开的链接,一定要关闭.

<%
 int questionid;
 int isvisable;
 questionid = Integer.parseInt(request.getParameter("questionid"));
 out.print(questionid);
 sql = "SELECT IsVisable from Questions where QuestionID ="+questionid;
 rs = smt.executeQuery(sql);
 out.println(rs);

while(rs.next())
  {
   isvisable = rs.getInt(1);
   out.println(isvisable);
   if(isvisable==1)
   {
     Statement smttmp   =   con.createStatement(); 
     sql = "update Questions set IsVisable = 0 ,IsOpen = 0 ,IsOpenDetial = 0 where QuestionID = "+questionid;
     smttmp.executeUpdate(sql);
     if(smttmp != null)
     {
     smttmp.close();
     }
     response.sendRedirect("mainform.jsp");
   }
   else if(isvisable==0)
   {
     Statement smttmp   =   con.createStatement(); 
     sql = "update Questions set IsVisable = 1 ,IsOpen = 0 ,IsOpenDetial = 0 where QuestionID = "+questionid;
     smttmp.executeUpdate(sql);
     if(smttmp != null)
     {
     smttmp.close();
     }
     response.sendRedirect("mainform.jsp");;
   }

}

if(con != null)
     {
     con.close();
     }
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312"> 
<title>
isvisable
</title>
</head>

</html>

最新文章

  1. [ACM_动态规划] 嵌套矩形
  2. mvc view-controller mvc annotation-driven
  3. [原创]上海好买基金招高级Java技术经理/运维主管/高级无线客户端开发等职位(内推)
  4. C#常用函数--通用篇
  5. vm克隆虚拟机网络配置
  6. Activity——思维导图
  7. C++流格式控制符的使用【来自网络】
  8. net windows Kafka
  9. [转载代码]VB.NET 中查询 Linq to SQL 执行时的SQL语句
  10. 我们一起学Windows Phone 8-01-开发环境搭建
  11. 手把手教你在ubuntu下创建桌面快捷方式
  12. SetThreadAffinityMask设置线程亲缘性
  13. Android--从系统Gallery获取图片
  14. css学习_css伪元素的本质
  15. Python递归调用
  16. 多端统一框架尝试--Taro
  17. 为 10000+ 业务系统提供数据可视化能力的 AntV 又进化了
  18. vue3.0 配置公共请求地址
  19. js闭包应用
  20. app分组

热门文章

  1. 洛谷P1991 无线通讯网(最小生成树性质+连通块)
  2. ES2.3.5版本的数据类型
  3. ipfs camp course c demo exercise 1
  4. Python读取MNIST数据集
  5. org.springframework.data.redis.RedisConnectionFailureException
  6. 前端学习 之 JavaScript 之 JSON
  7. 当在命令行中执行virtualenv venv时报此错误:&#39;utf-8&#39; codec can&#39;t decode byte 0xd5 in position 38: invalid continuation by
  8. Python - 编程技巧,语法糖,黑魔法,pythonic
  9. Pentaho6.1中D3可视化库的集成及数据联动的实现
  10. oracle连接种类