(1) 使用綠色版本JDK,解壓到一個(gè)目錄上D:\jdk1.6。
   (2) 使用綠色版本Tomcat,解壓到另一個(gè)目錄上D:\jdk1.6\tomcat5.5

    只要在bat文件D:\tomcat5.5\bin\catalina.bat,
    配置JAVA_HOME就可運(yùn)行了。
    增加:set JAVA_HOME="D:\jdk1.6",這樣就可以運(yùn)行了。

測(cè)試tomcat,訪問(wèn):  http://127.0.0.1:8080/,能打開(kāi)訪問(wèn)的頁(yè)面即可.

用一個(gè)簡(jiǎn)單的投票系統(tǒng)。http://127.0.0.1:8080/vote/
投票系統(tǒng)(請(qǐng)不要下載,已經(jīng)加密)

其中,有一個(gè)管理界面的mainform.jsp上有一個(gè)按鈕,修改數(shù)據(jù),所鏈接的是isvisable.jsp, 點(diǎn)擊修改后,又返回mainform.jsp.
問(wèn)題是: 不能刷新mainform.jsp,它還是顯示原來(lái)的數(shù)據(jù).

故我用了一個(gè)簡(jiǎn)單的解決方案:
         在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"); //去掉,不能直接返回,因更新數(shù)據(jù)庫(kù),需要時(shí)間
   }
   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"); //去掉,不能直接返回,因更新數(shù)據(jù)庫(kù),需要時(shí)間.
   }

  }
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<meta http-equiv="Refresh" content="1;url= mainform.jsp"> //等待1秒后,自動(dòng)刷新到主頁(yè)面.
<title>
isvisable
</title>
</head>

</html>


有沒(méi)有好的方法呢?

原來(lái)只要正常的關(guān)閉連接就可以了,感覺(jué)是不是這樣就提交了,特別是要關(guān)閉connection,
問(wèn)題解決了,看來(lái)還是要根據(jù)規(guī)范編寫(xiě)程序才行,打開(kāi)的鏈接,一定要關(guān)閉.

<%
 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>