javabean+jsp+sqlserver bbs
源代码在线查看: dispservlet.java~59~
package bookservlets;
import bookutil.DataDo;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class DispServlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=Big5";
//ini
public void init() throws ServletException {
}
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
String curpage=request.getParameter("page");
ArrayList records=null;
//get records and div pages
DataDo db=new DataDo();
records=db.dataQuery("select * from book order by g_id desc",5,curpage);
db.dataClose();
out.println("Leave Words List");
out.println("td{font-size:10pt;}");
out.println("Display List");
out.println("WRite---------------------------");
out.println("Manage");
out.println("Search with title: "+
"");
//display
for(int i=0;i ArrayList column=(ArrayList)records.get(i);
out.println(" out.println("bordercolor=#eeeeee style=\"table-layout:fixed;word-break:break-all\">");
out.println("");
String gender = "Lady";
if(column.get(db.getColumn("g_sex")).toString() == "1")gender = "Sir";
out.println("Name:"+new String(column.get(db.getColumn("g_name")).toString().getBytes("ISO8859_1"))+
" ("+gender+")");
out.println("QQ:"+column.get(db.getColumn("g_qq"))+"");
out.println("E_mail:"+column.get(db.getColumn("g_mail"))+"");
out.println("");
out.println(" ");
out.println("Title:"+new String(column.get(db.getColumn("g_title")).toString().getBytes("ISO8859_1"))+"");
out.println(" ");
out.println("Content:"+new String(column.get(db.getColumn("g_content")).toString().getBytes("ISO8859_1"))+"");
out.println("Master reply:"+column.get(db.getColumn("g_reply"))+"");
out.println("ID: "+column.get(db.getColumn("g_id"))+" IP:192.168.0.59 | ");
out.println("Date:"+column.get(db.getColumn("g_time"))+" ");
}
out.println("current page: "+db.cur_page+" |");
out.println(" total page: "+db.total_page+" |");
out.println(" next page |");
out.println(" previous page");
out.println("");
out.println("jump to:page");
out.println("");
}
//Clean up resources
public void destroy() {
}
}