<!--add_message.jsp-->
<%@ page import="java.sql.*" %>
<HTML>
<KOPF>
<TITLE>Nachricht zur Tabelle hinzufügen</TITLE>
</HEAD>
<KÖRPER>
<%
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)
Titel="";
if(content==null)
content="";
if(mail==null)
mail="";
if(name.length()==0)
out.println("留言人姓名不能为空!");
sonst if(title.length()==0)
out.println("留言主题不能为空!");
sonst if(content.length()==0)
out.println("留言内容不能为空!");
anders
{
java.util.Date date=new java.util.Date();
String datetime=new Timestamp(date.getTime()).toString();
versuchen
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:user_db";
Verbindung con=DriverManager.getConnection(url,"insher","insher");
PreparedStatement stm=con.prepareStatement("In Nachrichtenwerte einfügen (?,?,?,?,?)");
stm.setString(1,title);
stm.setString(2,name);
if(mail.length()==0)
stm.setString(3,null);
sonst stm.setString(3,mail);
stm.setString(4,datetime);
stm.setString(5,content);
versuchen
{
stm.executeQuery();
} Catch(Ausnahme e)
{}
con.close();
}
Catch (Ausnahme e)
{}
%>
<jsp:forward page="view_message.jsp" />
<%
}
%>
</body>
</html>
<!--add_message.jsp--
<%@ page import="java.sql.*" %>
<HTML>
<KOPF>
<TITLE>Nachricht zur Tabelle hinzufügen</TITLE>
</HEAD>
<KÖRPER>
<%
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)
Titel="";
if(content==null)
content="";
if(mail==null)
mail="";
if(name.length()==0)
out.println("留言人姓名不能为空!");
sonst if(title.length()==0)
out.println("留言主题不能为空!");
sonst if(content.length()==0)
out.println("留言内容不能为空!");
anders
{
java.util.Date date=new java.util.Date();
String datetime=new Timestamp(date.getTime()).toString();
versuchen
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:user_db";
Verbindung con=DriverManager.getConnection(url,"insher","insher");
PreparedStatement stm=con.prepareStatement("In Nachrichtenwerte einfügen (?,?,?,?,?)");
stm.setString(1,title);
stm.setString(2,name);
if(mail.length()==0)
stm.setString(3,null);
sonst stm.setString(3,mail);
stm.setString(4,datetime);
stm.setString(5,content);
versuchen
{
stm.executeQuery();
} Catch(Ausnahme e)
{}
con.close();
}
Catch (Ausnahme e)
{}
%>
<jsp:forward page="view_message.jsp" />
<%
}
%>
</body>
</html>
<!-- index.html -->
<HTML>
<KOPF>
<TITLE> Message Board </TITLE>
</HEAD>
<KÖRPER>
<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">Anzeige:</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>Weitere Informationen</font></a></TD>
<TD align="center" bgcolor="#88a6dd"><input type="reset" value="重新填写"></TD>
</TR>
</TABLE></TD>
</TR>
</FORM>
</TABLE></TD>
</TR>
</TABLE>
</BODY>
</HTML>
<HTML>
<KOPF>
<TITLE> Message Board </TITLE>
</HEAD>
<KÖRPER>
<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">Anzeige:</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>Weitere Informationen</font></a></TD>
<TD align="center" bgcolor="#88a6dd"><input type="reset" value="重新填写"></TD>
</TR>
</TABLE></TD>
</TR>
</FORM>
</TABLE></TD>
</TR>
</TABLE>
</BODY>
</HTML>
<!--view_message.jsp-->
<%@ page import="java.sql.*" %>
<HTML>
<KOPF>
<TITLE> zeigt die Nachricht in der Tabelle </TITLE> an
</HEAD>
<KÖRPER>
<p align="center">所有访客留言</p>
<hr>
<%
versuchen
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:user_db";
Verbindung con=DriverManager.getConnection(url,"insher","insher");
Anweisung 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");
Zeitstempel time=result.getTimestamp("time");
Datum date_time=new Date(time.getTime());
Zeit 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>Beispiel:</font></td>
<td colspan=3><%=title%></td></tr>
<tr><td bgcolor="#88a6dd"><font size=2>Vorlage:</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>Geben Sie Ihren Code ein:</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();
}
anders
{
out.println("目前还没有任何留言!");
con.close();
}
} Catch(Ausnahme e)
{out.println(e);}
%>
<p align="center"><a href="../message/index.html">Weitere Informationen</a></p>
</body>
</html>
<!--view_message.jsp-->
<%@ page import="java.sql.*" %>
<HTML>
<KOPF>
<TITLE> zeigt die Nachricht in der Tabelle </TITLE> an
</HEAD>
<KÖRPER>
<p align="center">所有访客留言</p>
<hr>
<%
versuchen
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:user_db";
Verbindung con=DriverManager.getConnection(url,"insher","insher");
Anweisung 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");
Zeitstempel time=result.getTimestamp("time");
Datum date_time=new Date(time.getTime());
Zeit 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>Beispiel:</font></td>
<td colspan=3><%=title%></td></tr>
<tr><td bgcolor="#88a6dd"><font size=2>Vorlage:</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>Geben Sie Ihren Code ein:</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();
}
anders
{
out.println("目前还没有任何留言!");
con.close();
}
} Catch(Ausnahme e)
{out.println(e);}
%>
<p align="center"><a href="../message/index.html">Weitere Informationen</a></p>
</body>
</html>