云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 利用Servlet和JSP设计并实现简单的图书管理系统

利用Servlet和JSP设计并实现简单的图书管理系统

  • 62 次阅读
  • 3 次下载
  • 2026/1/11 15:46:11

request.setAttribute(\

BookDBAccess dbAccess=new BookDBAccess();

List list=dbAccess.findAllBookByMostCon(bookName, ISBN, author, publishCom);

request.setAttribute(\

request.getRequestDispatcher(\response); } }

<7>显示图书清单

package com.imut.servlet; import java.io.IOException; import java.util.List;

import javax.servlet.ServletException; import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import com.imut.javabean.BookDBAccess; import com.imut.javabean.User;

import com.imut.javabean.UserDBAccess;

public class ListAllBookServlet 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 { request.setCharacterEncoding(\ response.setCharacterEncoding(\ BookDBAccess dbAccess=new BookDBAccess(); List list=dbAccess.findAllBook(); request.setAttribute(\

request.getRequestDispatcher(\response); } }

<8>用户定义

package com.imut.javabean; public class User {

private int userId; private String name; private String password; private String sex; private String feature; private String privence; private String author; private int userType; public User() { }

public User(int userId,String name, String password, String sex, }

public int getUserId() { }

public void setUserId(int userId) { }

public String getName() { }

public void setName(String name) { }

public String getPassword() { }

public void setPassword(String password) { }

public String getSex() {

this.password = password; return password; this.name = name; return name;

this.userId = userId; return userId;

String privence, String author,int userType) {

String feature,

this.userId = userId; this.name = name;

this.password = password; this.sex = sex;

this.feature = feature; this.privence = privence; this.author = author; this.userType = userType;

return sex;

}

public void setSex(String sex) { this.sex = sex;

}

public String getFeature() { return feature; }

public void setFeature(String feature) { this.feature = feature; }

public String getPrivence() { return privence;

}

public void setPrivence(String privence) { this.privence = privence; }

public String getAuthor() { return author;

}

public void setAuthor(String author) { this.author = author; }

public int getUserType() { return userType; }

public void setUserType(int userType) { this.userType = userType; }

}

<9>用户数据库

package com.imut.javabean; import java.sql.Connection;

import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException;

import com.imut.commmon.ConnectionFactory; import com.imut.commmon.ResourceClose; public class UserDBAccess { public User login(String name,String password) { User user=null; Connection conn=null;

PreparedStatement pstmt=null;

ResultSet rs=null;

}

}

try{ }

return user;

conn=ConnectionFactory.getConnection();

String sql=\pstmt=conn.prepareStatement(sql); pstmt.setString(1, name); pstmt.setString(2, password); rs=pstmt.executeQuery(); if(rs.next()){ }

e.printStackTrace();

ResourceClose.close(rs, pstmt, conn);

user=new User();

user.setUserId(rs.getInt(1)); user.setName(rs.getString(2)); user.setPassword(rs.getString(3)); user.setSex(rs.getString(4)); user.setFeature(rs.getString(5)); user.setPrivence(rs.getString(6)); user.setAuthor(rs.getString(7)); user.setUserType(rs.getInt(8));

password=?\

}catch (SQLException e) { }finally{

<10>图书定义

package com.imut.javabean; public class Book {

private int bookId; private String bookName; private String author; private String ISBN; private String publishCom; private float price;

private String publishDate; private String remark; public Book() { }

public Book(int bookId, String bookName, String isbn, String author,

String publishCom, float price, String publishDate, String

remark) {

this.bookId = bookId;

  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

request.setAttribute(\ BookDBAccess dbAccess=new BookDBAccess(); List list=dbAccess.findAllBookByMostCon(bookName, ISBN, author, publishCom); request.setAttribute(\ request.getRequestDispatcher(\response); } } 显示图书清单 package com.imut.servlet; import java.io.IOException; import java.util.List; import javax.servlet.ServletExc

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com