The functionality to be implemented is: Browsers can leave a message and can view the message, the administrator can process the message! This message board consists of 9 small programs, namely: Board.jsp; Message.html; OpenData .jsp; manger.jsp; password.jsp; check.jsp; delete.jsp; convert.jsp Now said the first: board.jsp His task is the main program of the entire message board, let the user leave a message, and provide paging Function! Before starting, we must establish a MyDate database in the MySQL database, build table named Message in Mudate: mysql> Create Table Message (Name Char (20), Email Char (40), Subject Char (60) , Time Char (60), SEX Char (10), MEMO TEXT, ID INT NOT NULL AUTO_INCREMENT, PRIMARY Key (ID)); Board.jsp code:
Head import = "java.sql. *"%> <% @ Page contenttype = "text / html; charSet = GB2312"%> <% @ include file = "openData.jsp" %> <% Int count = 0, LASTP, NUMF, NUML, PREP, NEXTP, PAGENO; IF (Request.GetParameter ("Pageno") == NULL) // Pageno: The page number page is Pageno = 0; Else Pageno = Integer. PARSEINT (Request.GetParameter ("Pageno")); SQL = "Select * from Message"; rs = smt.executeQuery (SQL); while (rs.next ()) count ; <% - count: How much message - %> LastP = (int) Math.ceil (Double) count / 5); <% - to calculate a few pages in this table: CEIL returns the minimum integer greater than or equal to its numeric parameters. Math.ceil (NUMBER) The Number parameter is a numerical expression. Note The return value is a minimum integer greater than or equal to its numeric parameters. -%> IF (PAGENO == 0 || Pageno> Lastp) Pageno = lastp; Numf = Pageno * 5-4; <% - Number of the first data of the message display _ID -%> NUML = Numf 4; <% - NUML: The last data number ID -%> IF (PAGENO == 1) PREP = 1; <% - prep: Previous -%> else prep = Pageno-1; if (PAGENO == lastp) nextp = lastp; else nextp = Pageno 1; SQL = "Select * from message where id betWeen" Numf "and" Numl; rs = smt.executeQuery (SQL); %>
Message board font>