如何让servlet输出内容到指定页
我的项有一个servlet显示数据库表信息的,不过是用servlet输出的,想把它的输出内容输出到指定页面中,怎么办??
比如我有一个showTable.servlet来连接数据库并找到了数据库内容并作出了输出,就是把下面的doget索要输出的内容输出到指定页面中??但是现在想把这个输出内容输出到页面a.jsp里面。该怎么做呀
附上代码
public void doGet(HttpServletRequest req, HttpServletResponse res){
PreparedStatement ps = null;
ResultSet rs = null;
try{
res.setContentType("text/html;charset=UTF-8");
PrintWriter pw = res.getWriter();
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/flightTicket","root","flight");
//分页
int pagerow = 5;
int nowpage = 1;
int pagelist = 0;
int pagecount = 0;
ps = conn.prepareStatement("select count(*) from passengerMessage");
rs = ps.executeQuery();
if(rs.next()){
pagelist = rs.getInt(1);
if(pagelist%pagerow == 0){
pagecount = pagelist/pagerow;
}else{
pagecount = pagelist/pagerow+1;
}
}
if(req.getParameter("spagecount") != null){
nowpage = Integer.parseInt(req.getParameter("spagecount"));
//System.out.println(req.getParameter("spagecount"));
}
//显示列表
Statement st = conn.createStatement();
rs = st.executeQuery("select * from passengerMessage limit "+(nowpage-1)*pagerow+","+pagerow);
System.out.println((nowpage-1)*pagerow+"(nowpage-1)*pagerow+"+pagerow+"pagerow");
pw.println("<table>");
pw.println("<tr><td>姓名</td><td>身份证</td><td>电话</td><td>删除</td></tr>");
while(rs.next()){
pw.println("<tr>");
pw.println("<td>"+rs.getString(1)+"</td>");
pw.println("<td>"+rs.getString(2)+"</td>");
pw.println("<td>"+rs.getString(3)+"</td>");
pw.println("<td><a href=Deletepassenger?IdCard="+rs.getString(2)+">删除</a></td>");
pw.println("</tr>");
}
pw.println("</table>");
//分页开始
//显示上一页
if(nowpage>1)
pw.println("<a href=SelectPassenger?spagecount="+(nowpage-1)+">上一页</a>");
for(int i =0; i<=pagecount; i++){
pw.println("<a&nbs