JSP与SQL SERVER的留言本
来源:互联网 发布:mysql 日志文件 编辑:程序博客网 时间:2024/04/30 22:59
<%@ page import="java.sql.*" %>
<%
String name=request.getParameter("name");
String mail=request.getParameter("mail");
String title=request.getParameter("title");
String content=request.getParameter("content");
if(name==null)
name="";
if(title==null)
title="";
if(content==null)
content="";
if(mail==null)
mail="";
if(name.length()==0)
out.println("留言人姓名不能为空!");
else if(title.length()==0)
out.println("留言主题不能为空!");
else if(content.length()==0)
out.println("留言内容不能为空!");
else
{
java.util.Date date=new java.util.Date();
String datetime=new Timestamp(date.getTime()).toString();
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:user_db";
Connection con=DriverManager.getConnection(url,"insher","insher");
PreparedStatement stm=con.prepareStatement("insert into message values(?,?,?,?,?)");
stm.setString(1,title);
stm.setString(2,name);
if(mail.length()==0)
stm.setString(3,null);
else stm.setString(3,mail);
stm.setString(4,datetime);
stm.setString(5,content);
try
{
stm.executeQuery();
} catch(Exception e)
{}
con.close();
}
catch (Exception e)
{}
%>
<%
}
%>
访客留言板
访客留言板
<%@ page import="java.sql.*" %>
所有访客留言
<%
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:user_db";
Connection con=DriverManager.getConnection(url,"insher","insher");
Statement stm=con.createStatement();
ResultSet result=stm.executeQuery("select count(*) from message");
int message_count=0;
if(result.next())
{
message_count=result.getInt(1);
result.close();
}
if(message_count>0)
{
result=stm.executeQuery("select * from message order by time desc");
while(result.next())
{
String title=result.getString("title");
String name=result.getString("name");
String mail=result.getString("mail");
Timestamp time=result.getTimestamp("time");
Date date_time=new Date(time.getTime());
Time time_time=new Time(time.getTime());
String content=result.getString("content");
%>
<%=title%>
留言人:
<%=name%> E-mail:
<%
out.println(""+mail+"");
%>
留言时间:
<%
out.println(""+date_time+" "+time_time+"");
%>
<%
out.println("("+message_count+")");
%>
<%=content%>
<%
out.println("
");
message_count--;
}
result.close();
con.close();
}
else
{
out.println("目前还没有任何留言!");
con.close();
}
} catch(Exception e)
{out.println(e);}
%>
我要留言
<%@ page import="java.sql.*" %>
所有访客留言
<%
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:user_db";
Connection con=DriverManager.getConnection(url,"insher","insher");
Statement stm=con.createStatement();
ResultSet result=stm.executeQuery("select count(*) from message");
int message_count=0;
if(result.next())
{
message_count=result.getInt(1);
result.close();
}
if(message_count>0)
{
result=stm.executeQuery("select * from message order by time desc");
while(result.next())
{
String title=result.getString("title");
String name=result.getString("name");
String mail=result.getString("mail");
Timestamp time=result.getTimestamp("time");
Date date_time=new Date(time.getTime());
Time time_time=new Time(time.getTime());
String content=result.getString("content");
%>
<%=title%>
留言人:
<%=name%> E-mail:
<%
out.println(""+mail+"");
%>
留言时间:
<%
out.println(""+date_time+time_time+"");
%>
<% JAVA天堂
out.println("("+message_count+")");
%>
<%=content%>
<%
out.println("
");
message_count--;
}
result.close();
con.close();
}
else
{
out.println("目前还没有任何留言!");
con.close();
}
} catch(Exception e)
{out.println(e);}
%>
我要留言
JAVA天堂
- JSP与SQL SERVER的留言本
- JSP与SQL SERVER的留言本
- JSP与SQL SERVER的留言本
- JSP与SQL SERVER的留言本
- JSP与SQL SERVER的留言本.
- JSP与SQL SERVER的留言本(转)
- jsp留言本 jsp课程设计
- 我的留言本
- 我的留言本
- 好玩的留言本
- 我的留言本
- jsp与SQL Server 2000 的连接
- 如何使用JSP+MySQL创建留言本
- 不良词语过滤 (jsp)例子:留言本
- BOSS留言本JSP版免费共享
- 如何使用jsp+mysql创建留言本
- jsp留言本时弹出debug视图
- Ajax实现的留言本
- 图形验证码的破解与设计
- 我的C#笔记……更新中
- 轻松使用JSP生成饼图
- 线程内核对象
- javascrip实现下拉框联动
- JSP与SQL SERVER的留言本
- 对图片上的颜色进行转换
- 如何写参数个数不定的函数(即类似printf的函数)
- jspSmartUpload上传下载全攻略
- Tomcat5.x中的虚拟主机配置方法
- 利用iText在JSP中生成PDF报表
- 女人50万年的进化
- JSP单页面网站文件管理器
- 分割字符串