清华大学出版社郭克华JavaWeb程序设计上机习题答案 下载本文

欢迎您,<% (\ 10-4、

<%@ page language=\<%@ page import=\

<%

ArrayList students=(ArrayList)(\ if(students!=null) {

for(int i=0;i<();i++) {

Student student=(Student)(i); ()+\ } } %>

Servlets、

package servlets; import ;

public class SearchStudent extends HttpServlet { public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { (\ String stuname=(\ if(stuname!=null) { StudentInfoDao infodao=new StudentInfoDao(); ArrayList infoList=null; try { infoList = (stuname); } catch (Exception e) { // TODO Auto-generated catch block (); } if(infoList!=null)

{ HttpSession session=(); (\ } } (\ } }

Beans、

(略。。。。) Dao、

package dao; import ;

public class StudentInfoDao { public ArrayList queryAllStudents(String stuname) throws Exception { Connection conn = null; ArrayList students= new ArrayList(); try { //获取连接 String url=\ conn = (url, \ // 运行SQL语句 String sql = \LIKE '%\ Statement stat = (); ResultSet rs = (sql); while ()) {

//实例化VO Student student = new Student(); (\ (\ (\ (student); } (); (); } catch (SQLException e) { (); } finally { try {// 关闭连接 if (conn != null) { (); conn = null; }

}

}

} catch (Exception ex) { } }

return students;