servlet问题

来源:百度知道 编辑:UC知道 时间:2024/05/15 08:39:57
利用servlet使数据库里的所有信息打印在网页上而且信息是写在表格里~
表格是动态的,几条信息就显示几行表格~~快帮帮我~~我狂追加分~怕把分浪费了~~~~~~~~~~~~~~~~~~~~~~~~``写详细点啊数据库语句就不用写了
主要写servlet如何把信息全部输出在网页上和叫表格随着信息的条数而增长还是减少!!!

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.*;
public class DBServlet extends HttpServlet {
static final String url ="jdbc:mysql://localhost:3306/test";
static final String jdbcclass = "org.gjt.mm.mysql.Driver";
public void init(ServletConfig config) throws ServletException {
super.init(config);
try { //1. Load the JDBC driver.
Class.forName(jdbcclass);
}
catch (Exception e) {
e.printStackTrace();
}
}
public void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
res.setContentType("text/html");
Connection con = null;
PrintWriter out = res.getWriter();
try {
//2. get the connection from t