//====================将药品信息填入数据对象并存入Vector中================
if(rs2.next()){
all_count=rs2.getLong(1);//取得总条数
}
if(rs2!=null)rs2.close();
while(rs.next()){
medicinelist m =新建 medicinelist ();
m.setYpbm(rs.getInt("ypbm"));
m.setZlmc(rs.getString("zlmc"));
m.setClmc(rs.getString("clmc"));
m.setDlmc(rs.getString("dlmc"));
m.setYpm(rs.getString("ypm"));
m.setZyyx(rs.getString("zyyx"));
m.setYpzy(rs.getString("ypzy"));
m.setClbm(clbm);
m.setDlbm(dlbm);
m.setZlbm(zlbm);
list.addElement(m);
}
//----------------------------------------------------------
if(rs!=null)rs.close();
stmt.setMaxRows(0);
if(stmt!=null)stmt.close();
connMgr.freeConnection("medicine",con);
//========================存入session中===========================
同步(会议){
session.setAttribute("medicinelist",list);
}
//-----------------------------------------------
}抓住( SQLException e ){
connMgr.freeConnection("medicine",con);
response.sendRedirect("/Medicine/sql_error.html");
归还;}
//=======================重定向到一个JSP页面==========================
串 url="/medicine/querymedicine.jsp?all_count="+all_count;
ServletContext sc = getServletContext ();
RequestDispatcher rd = sc.getRequestDispatcher(url);
rd.forward(request,反应);
//-------------------------------------------------------
}
公共的空破坏(){
// =================== 在Servlet退出时终止数据库连接,取消Statement对象
如果( connMgr ! =null ) connMgr.release();
//------------------------------------------------------------------------
}
//========================处理HTTP Post 请求 ============================
公共的空的 doPost ( HttpServletRequest请求 , HttpServletResponse反应)
扔 ServletException , IOException {
doGet (请求 ,反应);
}
//==========================取得 Servlet 信息 ============================
公共的绳 getServletInfo (){
回来 "medicine.querymedicine信息& quot ;;
}
}
l querymedicine.jsp
<%@页面语言=& quot ; java & quot ;session=& quot ;真实的& quot ; import="java.util.*,
Medicine.method, Medicine.medicinelist"contentType="text/html;charset=gbk" %>
<手迹语言=& quot ; JavaScript & quot ;>
功能下一条 (){
var ls_pos=document.form2.maxpos.value;
document.location="/servlet/Medicine.querymedicine?pos="+ls_pos;
}
功能详细( ypbm ){
document.location="/servlet/Medicine.Detail?ypbm="+ypbm;
}
</script>