<% @ Page Import = "java.sql. *"%>
add message inTo Table title>
HEAD>
<%
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)
""; "
IF (mail == null)
Mail = ""
IF (Name.length () == 0)
Out.println ("The name of the message cannot be empty!");
Else IF (title.length () == 0)
Out.println ("" The theme of the message cannot be empty! ");
Else IF (content.length () == 0)
Out.println ("The message cannot be empty!");
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 (",,?,?,?,?)"); 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) {}%> <%}%> body> html>
add message inTo Table title> head> <% 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 ("The name of the message cannot be empty!"); Else IF (title.length () == 0) Out.println ("message topic can not be empty!"); else IF () == 0) Out.println ("message content is not empty!"); else {java.util.date Date = new java.util.date (); string datetime = new timestamp (Date). GetTime ()). toString (); Try {class.forname ("sun.jdbc.odbc.jdbcodbcodbdriver"); 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) {}%>
<%}%> body> html>
message board title> head> Visitor message board td> tr> < Tr> | |