Source code of a message board written in Java (2)

Source: Internet
Author: User

Iii. reply. jsp
==========================================
& Lt html & gt & lt head & gt
& Lt META content = "text/html; charset = gb2312" http-equiv = Content-Type & gt

& Lt title & gt Zhangjiajie Yellow Pages (114 on the Internet) & lt/title & gt & lt/head & gt
& Lt style type = "text/css" & gt
& Lt! --
BODY {FONT-FAMILY: "", "Arial Narrow", "Times New Roman"; FONT-SI
ZE: 9pt}
. P1 {FONT-FAMILY: "", "Arial Narrow", "Times New Roman"; FONT-SIZ
E: 12pt}
A: link {COLOR: # 00793d; TEXT-DECORATION: none}
A: visited {TEXT-DECORATION: none}
A: hover {TEXT-DECORATION: underline}
TD {FONT-FAMILY: "", "Arial Narrow", "Times New Roman"; FONT-SIZE
: 9pt}
. P2 {FONT-FAMILY: "", "Arial Narrow", "Times New Roman"; FONT-SIZ
E: 9pt; LINE-HEIGHT: 150%}
. P3 {FONT-FAMILY: "", "Arial Narrow", "Times New Roman"; FONT-SIZ
E: 9pt; LINE-HEIGHT: 120%}

-- & Gt
& Lt/style & gt


& Lt body & gt


& Lt % @ page contentType = "text/html; charset = GB2312" % & gt
& Lt % @ page language = "java" import = "java. SQL. *" % & gt
& Lt jsp: useBean id = "testInq" scope = "page" class = "ymbean. opDb"/& gt
& Lt %
Int pages = 1;
Int pagesize = 10;
Int count = 0;
Int totalpages = 0;

String countsql = "", inqsql = "", updatesql = "", lwhere = "", insertsql = "", st =
"";

String lw_title = "\", lw_author = ", pagetitle =" \ ", author_http =" ", author_e
Mail = "", lw_ico = "0 ",
Lw_content = "", lw_class1 = "";
String author_ip = "", lw_time = "", lw_class2 = "", lw_type = "", zt_time = "", zt
_ Author = "";
Int answer_num = 0, click_num = 0;
Int inquire_item = 1;
String inquire_itemt = "", inquire_value = "";
String lurlt = "& lt a href = reply. jsp? ";

Lwhere = "where"; // only show the primary sticker

/*
Enumeration e = request. getParameterNames ();
While (e. hasMoreElements ()){
String name = (String) e. nextElement ();
*/
Try {
// Obtain the order number of the displayed pages
Pages = new Integer (request. getParameter ("pages"). intValue ();
} Catch (Exception e ){}
Try {
// Retrieve query parameters
Lw_class1 = new String (request. getParameter ("lw_class1"). getBytes
("ISO8859_1 "));
Lw_class2 = new String (request. getParameter ("lw_class2"). getBytes
("ISO8859_1 "));
Zt_time = new String (request. getParameter ("zt_time"). getBytes ("IS
O8859_1 "));
Zt_author = new String (request. getParameter ("zt_author"). getBytes
("ISO8859_1 "));

Lwhere = "where (lw_class1 =" + lw_class1 + "and lw_class2 =" + lw _
Class2 +
"And (lw_time =" + zt_time + "or zt_time =" + zt_time +
") And (author_email =" + zt_author + "or zt_author =" + zt
_ Author + "))";
Lurlt = lurlt + "lw_class1 =" + lw_class1 + "& lw_class2 =" + lw_class2 + "& zt
_ Time = "+ zt_time +
"& Zt_author =" + zt_author + "&";
// Out. print (lwhere );
} Catch (Exception e) {// out. print ("error1:" + e + "& lt hr & gt ");
}

Try {
// Get parameter message content
Lw_class1 = new String (request. getParameter ("lw_class1"). getBytes ("ISO
8859_1 "));
Lw_class2 = new String (request. getParameter ("lw_class2"). getBytes ("ISO
8859_1 "));
Lw_title = new String (request. getParameter ("lw_title"). getBytes ("ISO88
59_1 "));
Lw_author = new String (request. getParameter ("lw_author"). getBytes ("ISO
8859_1 "));
Pagetitle = new String (request. getParameter ("pagetitle"). getBytes ("ISO
8859_1 "));
Author_http = new String (request. getParameter ("author_http"). getBytes (
"ISO8859_1 "));
Author_email = new String (request. getParameter ("author_email"). getByte
S ("ISO8859_1 "));
Zt_time = new String (request. getParameter ("zt_time"). getBytes ("ISO8859
_ 1 "));
Zt_author = new String (request. getParameter ("zt_author"). getBytes ("ISO
8859_1 "));
Lw_ico = request. getParameter ("gifface ");

} Catch (Exception e ){}

Try {
Lw_content = new String (request. getParameter ("lw_content"). getBytes ("I
SO8859_1 "));
String requestMethod = request. getMethod ();
RequestMethod = requestMethod. toUpperCase ();
If (requestMethod. indexOf ("POST") & lt 0)
{Out. print ("illegal operation! ");
Return;
}

// Form other data items
Author_ip = request. getRemoteAddr ();
Lw_time = testInq. getCurrentDate ("yyyyMMddHHmmss ");
Lw_type = "" + "c"; // slave post
Answer_num = 0;
Click_num = 0;
// ==========================
St = ",";
// Ensure that the length of all data items in the message is within the normal range
If (lw_title.length () & gt50) lw_title = lw_title.substring (0, 50 );
If (lw_author.length () & gt20) lw_author = lw_author.substring (0, 20 );
If (author_http.length () & gt40) author_http = author_http.substring (0, 40 );

If (author_email.length () & gt50) author_email = author_email.substring (0, 4
0 );
If (zt_author.length () & gt50) zt_author = zt_author.substring (0, 40 );
If (lw_content.length () & gt4000) lw_content = lw_content.substring (0,4000)
;

Insertsql = "insert into guestbook values (" + lw_title + st + lw_author + st +
Author_http + st +
Author_email + st + lw_ico + st + lw_time + "," + answer_num + "," + cli
Ck_num + "," +
Author_ip + st + lw_class1 + st + lw_class2 + st + lw_type + st + zt_time
+ St + zt_author + st +
Lw_content + ")";
// Out. print (insertsql );
// Insert a message
Try {
St=testInq.exe cuteUpdate (insertsql );
If (st. indexOf ("executeUpdate OK") & lt 0)
Out. print ("msg =" + st );
Else
{
Updatesql = "update guestbook set answer_num = answer_num + 1" + l
Where;
// Increase the number of replies
Try {
St=testInq.exe cuteUpdate (updatesql );
If (st. indexOf ("executeUpdate OK") & lt 0)
Out. print ("msg =" + st );
} Catch (Exception e ){}
}
} Catch (Exception e) {out. print ("message error:" + e );}
} Catch (Exception e ){}
% & Gt

& Lt %
// Verify the validity of the entered message.
String ljs = "& lt SCRIPT language = JavaScript & gt" +
"& Lt! -- "+
"Function ValidInput ()" +
"{If (document. sign. lw_author.value =" ")" +
"{Alert (" enter your name. ");" +
"Document. sign. lw_author.focus ();" +
"Return false;}" +
"If (document. sign. lw_title.value =" ")" +
"{Alert (" Enter the message subject. ");" +
"Document. sign. lw_title.focus ();" +
"Return false;}" +
"If (document. sign. author_email.value! = "") "+
"{If (document. sign. author_email.value.indexOf (" @ ") & lt 0) // (document
. Sign. author_email.value.indexOf (":")! =-1) "+
"{Alert (" the EMail you entered is invalid. Please enter a valid Email! ");" +
"Document. sign. author_emaill.focus ();" +
"Return false;" +
"}" +
"}" +
"Return true;" +
"}" +
"Function ValidSearch ()" +
"{If (document. frmsearch. findstr. value =" ")" +
"{Alert (" Empty strings cannot be searched! ");" +
"Document. frmsearch. findstr. focus ();" +
"Return false;}" +
"}" +
"// -- & Gt" +
"& Lt/SCRIPT & gt ";
Out. print (ljs );
% & Gt


& Lt %
// Display a message posted last time
Countsql = "select count (lw_title) from guestbook" + lwhere;
Inqsql = "select lw_title, lw_author, lw_time, lw_content, author_ip," +
"Author_email from guestbook" + lwhere + "order by lw_time desc
";
Updatesql = "update guestbook set click_num = click_num + 1" + lwhere;

// Increase the browser count
Try {
St=testInq.exe cuteUpdate (updatesql );
If (st. indexOf ("executeUpdate OK") & lt 0)
Out. print ("msg =" + st );
} Catch (Exception e ){}

// Out. print (inqsql );
If (pages & gt0)
{
Try {
Try {
Resu

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.