用绿色版TOMCAT和绿色版JDK安装一个WEB服务器
(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>
最新文章
- [ACM_动态规划] 嵌套矩形
- mvc view-controller mvc annotation-driven
- [原创]上海好买基金招高级Java技术经理/运维主管/高级无线客户端开发等职位(内推)
- C#常用函数--通用篇
- vm克隆虚拟机网络配置
- Activity——思维导图
- C++流格式控制符的使用【来自网络】
- net windows Kafka
- [转载代码]VB.NET 中查询 Linq to SQL 执行时的SQL语句
- 我们一起学Windows Phone 8-01-开发环境搭建
- 手把手教你在ubuntu下创建桌面快捷方式
- SetThreadAffinityMask设置线程亲缘性
- Android--从系统Gallery获取图片
- css学习_css伪元素的本质
- Python递归调用
- 多端统一框架尝试--Taro
- 为 10000+ 业务系统提供数据可视化能力的 AntV 又进化了
- vue3.0 配置公共请求地址
- js闭包应用
- app分组
热门文章
- 洛谷P1991 无线通讯网(最小生成树性质+连通块)
- ES2.3.5版本的数据类型
- ipfs camp course c demo exercise 1
- Python读取MNIST数据集
- org.springframework.data.redis.RedisConnectionFailureException
- 前端学习 之 JavaScript 之 JSON
- 当在命令行中执行virtualenv venv时报此错误:&#39;utf-8&#39; codec can&#39;t decode byte 0xd5 in position 38: invalid continuation by
- Python - 编程技巧,语法糖,黑魔法,pythonic
- Pentaho6.1中D3可视化库的集成及数据联动的实现
- oracle连接种类