Java EE高级编程

时间:2015-01-13 11:54:05
【文件属性】:

文件名称:Java EE高级编程

文件大小:149KB

文件格式:DOC

更新时间:2015-01-13 11:54:05

一.实验目的

一.实验目的 1.掌握JSTL常见标记 二.实验任务 1.编写一个用户信息浏览页面,用JSTL 实现 三.实验软件 JDK5.0 Tomcat5.0 MyEclipse 四.实验步骤 1. 利用MyEclipse创建Web Application --- MyWebApp ,选择JSTL1.1支持 ( 10分) 2. 创建学生表 tb_user ( 20分) 3. 创建BOJO --- User ( 20分) public class Users implements java.io.Serializable { private Integer userId; private String userName; private String password; public Integer getUserId() { return this.userId; } public void setUserId(Integer userId) { this.userId = userId; } public String getUserName() { return this.userName; } public void setUserName(String userName) { this.userName = userName; } public String getPassword() { return this.password; } public void setPassword(String password) { this.password = password; }} 4. 创建DAO ---UserDAO ( 20分) public class UserDAO { public List getAll() { List list = new ArrayList(); String sql="select * from Users "; DBUtil db = new DBUtil(); ResultSet rs = db.executeQuery(sql) ; try { while ( rs.next() ) { User u = new User( rs.getInt("userId"), rs.getString("userName"),rs.getString("password")); list.add( u ); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return list; } } 5.编写UserSevlet ( 20分) public class UserServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException { doPost(request, response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { UserDAO userdao = new UserDAO(); request.setAttribute("userList", userdao.getAll() ); String url = "/User/listUser.jsp" ; request.getRequestDispatcher(url).forward(request, response) ; } 6.编写user.index ( 10分)


网友评论