Jsp user message board program

Source: Internet
Author: User

 

The code is as follows: Copy code
<Table class = "k123"
Style = "MARGIN-TOP: 15px; BORDER-COLLAPSE: collapse"
Bordercolor = "# cccccc" cellspacing = "0" cellpadding = "4"
Width = "360" align = "center" bgcolor = "# ffffff" border = "1">
<Tbody>
<Tr>
<Td class = "f12black" align = "right"
Height = "18"> Sender: </td>
<Td class = "f12black" align = "left"> <label>
<Input class = "input" style = "FONT-SIZE: 14px; WIDTH: 100px; HEIGHT: 16px "maxlength =" 36 "size =" 22 "name =" name "/>
</Label> </td>
</Tr>
<Tr>
<Td class = "f12black" align = "right" width = "84"
Bgcolor = "# f9f9f9"> Message Title: </td>
<Td class = "f12black" align = "left" width = "254" bgcolor = "# f9f9f9">
<Input class = "input" style = "FONT-SIZE: 14px; WIDTH: 160px; HEIGHT: 19px "maxlength =" 36 "size =" 18 "name =" title "/> </td>
</Tr>
<Tr>
<Td class = "f12black" align = "right"> Message Content: </td>
<Td class = "f12black" align = "left">
<Textarea class = "input" style = "FONT-SIZE: 14px" name = "content" rows = "4" cols = "30"> </textarea> </td>
</Tr>
<Tr>
<Td class = "f12black" align = "middle" colspan = "2">
<Input type = "button" value = "submit your message" name = "cmdOk"/>
& Nbsp; </td>
</Tr>
</Tbody>
</Table>


                         
Save message
                       

The code is as follows: Copy code

<%
String url = "jdbc: mysql: // localhost/zkh1__db? User = zkh131 & password = n3a9q2e3 & useUnicode = true & characterEncoding = gb2312 ";
Class. forName ("org. gjt. mm. mysql. Driver"). newInstance ();
Connection conn = DriverManager. getConnection (url );


Java. text. SimpleDateFormat formatter = new java. text. SimpleDateFormat ("yyyy-MM-dd ");
Java. util. Date currentTime = new java. util. Date ();
String nowTime = formatter. format (currentTime );
If (request. getParameter ("title") = "fdsafdsaf_fd_XXX "){
String namec = new String (request. getParameter ("name"). getBytes ("iso-8859-1 "));
String titlec = new String (request. getParameter ("title"). getBytes ("iso-8859-1 "));
String contentc = new String (request. getParameter ("content"). getBytes ("iso-8859-1 "));
Statement stmtADDd = conn. createStatement ();
String Sqladd = "insert into hl_book (Name, Title, Content, thisTime) values ('" + namec + "', '" + titlec + "', '"+ contentc +"', '"+ nowTime + "')";
Int addd1_stmtaddd.exe cuteUpdate (Sqladd );
Out. print ("<script type =" text/javascript "> alert (" Your message is successful. Thank you for your attention! "); Window. location. href = 'service. jsp '; </script> ");
Return;
}
%>
 


Show message
                         

The code is as follows: Copy code
<%
ResultSet rsn1_stmt1.exe cuteQuery ("Select * from hl_book where Rebook! = ''Order by id desc limit 1 ");
If (Rsn. next ()){
%>
<Table style = "MARGIN-TOP: 5px; MARGIN-RIGHT: 12px" width = "94%" align = "center" bgcolor = "# cccccc" border = "0">
<Tbody>
<Tr>
<Td align = "middle" width = "81" bgcolor = "# eeeeee" height = "25"> subject </td>
<Td align = "left" width = "466" bgcolor = "# eeeeee" height = "25"> & nbsp; <% = Rsn. getString ("Title") %> & nbsp; [<% = Rsn. getString ("thisTime") %>] </td>
</Tr>
<Tr>
<Td align = "middle" bgcolor = "# ffffff" height = "25"> content </td>
<Td align = "left" bgcolor = "# ffffff" height = "25"> & nbsp; <% = Rsn. getString ("Content") %> </td>
</Tr>
<Tr>
<Td align = "middle" bgcolor = "# ffffff" height = "25"> <font color = "# ff0000"> Reply content </font> </td>
<Td align = "left" bgcolor = "# ffffff" height = "25"> <font color = "# ff0000"> & nbsp; <% = Rsn. getString ("Rebook") %> </font> </td>
</Tr>
</Tbody>
</Table>
<%
 }
Rsn. close ();
%>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.