<!--add_message.jsp-->
<%@ page import="java.sql.*" %>
<HTML>
<TÊTE>
<TITLE>ajouter un message dans le tableau </TITLE>
</HEAD>
<CORPS>
<%
String nom=request.getParameter("nom");
String mail=request.getParameter("mail");
String title=request.getParameter("titre");
String content=request.getParameter("content");
si(nom==null)
nom="";
si (titre == nul)
titre="";
si (contenu == nul)
contenu="";
si(mail==null)
courrier="";
si(nom.longueur()==0)
out.println("留言人姓名不能为空!");
sinon si(titre.longueur()==0)
out.println("留言主题不能为空!");
sinon si(content.length()==0)
out.println("留言内容不能为空!");
autre
{
java.util.Date date=new java.util.Date();
String datetime=new Timestamp(date.getTime()).toString();
essayer
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Chaîne url="jdbc:odbc:user_db";
Connexion con=DriverManager.getConnection(url,"insher","insher");
PreparedStatement stm=con.prepareStatement("insérer dans les valeurs du message(?,?,?,?,?)");
stm.setString(1,titre);
stm.setString(2,nom);
si(mail.length()==0)
stm.setString(3,null);
sinon stm.setString(3,mail);
stm.setString(4,datetime);
stm.setString(5,content);
essayer
{
stm.executeQuery();
} catch(Exception e)
{}
con.close();
}
attraper (exception e)
{}
%>
<jsp:forward page="view_message.jsp" />
<%
}
%>
</corps>
</html>
<!--add_message.jsp--
<%@ page import="java.sql.*" %>
<HTML>
<TÊTE>
<TITLE>ajouter un message dans le tableau </TITLE>
</HEAD>
<CORPS>
<%
String nom=request.getParameter("nom");
String mail=request.getParameter("mail");
String title=request.getParameter("titre");
String content=request.getParameter("content");
si(nom==null)
nom="";
si (titre == nul)
titre="";
si (contenu == nul)
contenu="";
si(mail==null)
courrier="";
si(nom.longueur()==0)
out.println("留言人姓名不能为空!");
sinon si(titre.longueur()==0)
out.println("留言主题不能为空!");
sinon si(content.length()==0)
out.println("留言内容不能为空!");
autre
{
java.util.Date date=new java.util.Date();
String datetime=new Timestamp(date.getTime()).toString();
essayer
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Chaîne url="jdbc:odbc:user_db";
Connexion con=DriverManager.getConnection(url,"insher","insher");
PreparedStatement stm=con.prepareStatement("insérer dans les valeurs du message(?,?,?,?,?)");
stm.setString(1,titre);
stm.setString(2,nom);
si(mail.length()==0)
stm.setString(3,null);
sinon stm.setString(3,mail);
stm.setString(4,datetime);
stm.setString(5,content);
essayer
{
stm.executeQuery();
} catch(Exception e)
{}
con.close();
}
attraper (exception e)
{}
%>
<jsp:forward page="view_message.jsp" />
<%
}
%>
</corps>
</html>
<!-- index.html -->
<HTML>
<TÊTE>
<TITLE> forum de discussion </TITLE>
</HEAD>
<CORPS>
<TABLE width="90%" align="center" border=1 cellpacing="0" cellpadding="0" bordercolordark="#88a6dd" bordercolorlight="#88a6dd">
<TR>
<TD align="center" bgcolor="#88a6dd">访客留言板</TD>
</TR>
<TR>
<TD><TABLE align="center" border=1 cellpacing="0" cellpadding="0" bordercolordark="#88a6dd" bordercolorlight="#88a6dd">
<FORM ACTION="add_message.jsp">
<TR>
<TD>姓名:</TD>
<TD bgcolor="#88a6dd"><input type="text" name="name" size=25></TD>
</TR>
<TR>
<TD bgcolor="#88a6dd">E-mail :</TD>
<TD bgcolor="#88a6dd"><input type="text" name="mail" size=25></TD>
</TR>
<TR>
<TD>主题:</TD>
<TD bgcolor="#88a6dd"><input type="text" name="title" size=25></TD>
</TR>
<TR>
<TD valign="top" bgcolor="#88a6dd">留言:</TD>
<TD><textarea name="content" rows=7 cols=25></textarea></TD>
</TR>
<TR>
<TD colspan=3><TABLE align="center" width="100%" Cellpacing="0" cellpadding="0" bordercolordark="#88a6dd" bordercolorlight="#88a6dd">
<TR>
<TD align="center" bgcolor="#88a6dd"><input type="submit" value="提交留言"></TD>
<TD align="center"><a href="view_message.jsp"><font size=2>查看留言</font></a></TD>
<TD align="center" bgcolor="#88a6dd"><input type="reset" value="重新填写"></TD>
</TR>
</TABLE></TD>
</TR>
</FORM>
</TABLE></TD>
</TR>
</TABLE>
</CORPS>
</HTML>
<HTML>
<TÊTE>
<TITLE> forum de discussion </TITLE>
</HEAD>
<CORPS>
<TABLE width="60%" align="center" border=1 cellpacing="0" cellpadding="0" bordercolordark="#88a6dd" bordercolorlight="#88a6dd">
<TR>
<TD align="center" bgcolor="#88a6dd">访客留言板</TD>
</TR>
<TR>
<TD><TABLE align="center" border=1 cellpacing="0" cellpadding="0" bordercolordark="#88a6dd" bordercolorlight="#88a6dd">
<FORM ACTION="add_message.jsp">
<TR>
<TD>姓名:</TD>
<TD bgcolor="#88a6dd"><input type="text" name="name" size=25></TD>
</TR>
<TR>
<TD bgcolor="#88a6dd">E-mail :</TD>
<TD bgcolor="#88a6dd"><input type="text" name="mail" size=25></TD>
</TR>
<TR>
<TD>主题:</TD>
<TD bgcolor="#88a6dd"><input type="text" name="title" size=25></TD>
</TR>
<TR>
<TD valign="top" bgcolor="#88a6dd">留言:</TD>
<TD><textarea name="content" rows=7 cols=25></textarea></TD>
</TR>
<TR>
<TD colspan=3><TABLE align="center" width="100%" Cellpacing="0" cellpadding="0" bordercolordark="#88a6dd" bordercolorlight="#88a6dd">
<TR>
<TD align="center" bgcolor="#88a6dd"><input type="submit" value="提交留言"></TD>
<TD align="center"><a href="view_message.jsp"><font size=2>查看留言</font></a></TD>
<TD align="center" bgcolor="#88a6dd"><input type="reset" value="重新填写"></TD>
</TR>
</TABLE></TD>
</TR>
</FORM>
</TABLE></TD>
</TR>
</TABLE>
</CORPS>
</HTML>
<!--view_message.jsp-->
<%@ page import="java.sql.*" %>
<HTML>
<TÊTE>
<TITLE> afficher le message dans le tableau </TITLE>
</HEAD>
<CORPS>
<p align="center">所有访客留言</p>
<hr>
<%
essayer
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Chaîne url="jdbc:odbc:user_db";
Connexion con=DriverManager.getConnection(url,"insher","insher");
Instruction stm=con.createStatement();
ResultSet result=stm.executeQuery("select count(*) from message");
int message_count=0;
si (résultat. suivant ())
{
message_count=result.getInt(1);
result.close();
}
si (compte_message>0)
{
result=stm.executeQuery("select * from message order by time desc");
while(result.next())
{
String title=result.getString("titre");
String nom=result.getString("nom");
String mail=result.getString("mail");
Horodatage time=result.getTimestamp("time");
Date date_time=new Date(time.getTime());
Heure time_time=new Time(time.getTime());
String content=result.getString("content");
%>
<TABLE width="100%" align="center" border=1 cellpacing="0" cellpadding="0" bordercolordark="#000000" bordercolorlight="#88a6dd">
<tr><td bgcolor="#88a6dd"><font size=2>主题:</font></td>
<td colspan=3><%=title%></td></tr>
<tr><td bgcolor="#88a6dd"><font size=2>留言人 :</font></td>
<td><%=name%></td><td bgcolor="#88a6dd"><font size=2>E-mail :</font></td>
<td>
<%
out.println("<a href=mailto:"+mail+">"+mail+"</a>");
%>
</td></tr>
<tr><td bgcolor="#88a6dd"><font size=2>留言时间:</font></td><td colspan=3>
<%
out.println("<font size=2>"+date_time+" "+time_time+"</font>");
%>
</td></tr>
<tr><td align="center">
<%
out.println("("+message_count+")");
%>
</td>
<td colspan=3><%=content%>
</td></tr>
</table>
<%
out.println("<hr>");
message_count--;
}
result.close();
con.close();
}
autre
{
out.println("目前还没有任何留言!");
con.close();
}
} catch(Exception e)
{out.println(e);}
%>
<p align="center"><a href="../message/index.html">我要留言</a></p>
</corps>
</html>
<!--view_message.jsp-->
<%@ page import="java.sql.*" %>
<HTML>
<TÊTE>
<TITLE> afficher le message dans le tableau </TITLE>
</HEAD>
<CORPS>
<p align="center">所有访客留言</p>
<hr>
<%
essayer
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Chaîne url="jdbc:odbc:user_db";
Connexion con=DriverManager.getConnection(url,"insher","insher");
Instruction stm=con.createStatement();
ResultSet result=stm.executeQuery("select count(*) from message");
int message_count=0;
si (résultat. suivant ())
{
message_count=result.getInt(1);
result.close();
}
si (compte_message>0)
{
result=stm.executeQuery("select * from message order by time desc");
while(result.next())
{
String title=result.getString("titre");
String nom=result.getString("nom");
String mail=result.getString("mail");
Horodatage time=result.getTimestamp("time");
Date date_time=new Date(time.getTime());
Heure time_time=new Time(time.getTime());
String content=result.getString("content");
%>
<TABLE width="100%" align="center" border=1 cellpacing="0" cellpadding="0" bordercolordark="#000000" bordercolorlight="#88a6dd">
<tr><td bgcolor="#88a6dd"><font size=2>主题:</font></td>
<td colspan=3><%=title%></td></tr>
<tr><td bgcolor="#88a6dd"><font size=2>留言人 :</font></td>
<td><%=name%></td><td bgcolor="#88a6dd"><font size=2>E-mail :</font></td>
<td>
<%
out.println("<a href=mailto:"+mail+">"+mail+"</a>");
%>
</td></tr>
<tr><td bgcolor="#88a6dd"><font size=2>留言时间:</font></td><td colspan=3>
<%
out.println("<font size=2>"+date_time+time_time+"</font>");
%>
</td></tr>
<tr><td align="center">
<%
out.println("("+message_count+")");
%>
</td>
<td colspan=3><%=content%>
</td></tr>
</table>
<%
out.println("<hr>");
message_count--;
}
result.close();
con.close();
}
autre
{
out.println("目前还没有任何留言!");
con.close();
}
} catch(Exception e)
{out.println(e);}
%>
<p align="center"><a href="../message/index.html">我要留言</a></p>
</corps>
</html>