zoukankan      html  css  js  c++  java
  • 20201122 千锤百炼软工人

    完善一下昨天的那个图书管理系统

    package Bean;

    public class Beanid {
    private String id;
    private String password;
    private String jiese;


    public String getJiese() {
    return jiese;
    }
    public void setJiese(String jiese) {
    this.jiese = jiese;
    }
    public String getId() {
    return id;
    }
    public void setId(String id) {
    this.id = id;
    }
    public String getPassword() {
    return password;
    }
    public void setPassword(String password) {
    this.password = password;
    }

    public Beanid(){}
    public Beanid(String password) {

    this.password = password;
    };
    public Beanid(String jiese,String id, String password) {
    this.jiese = jiese;
    this.id = id;
    this.password = password;

    }
    }

    package Bean;

    public class Book {
    private String idc;
    private String name;
    private String peoplenumber;
    private String author;
    private String chubanshe;
    public String getIdc() {
    return idc;
    }
    public void setIdc(String idc) {
    this.idc = idc;
    }
    public String getName() {
    return name;
    }
    public void setName(String name) {
    this.name = name;
    }
    public String getPeoplenumber() {
    return peoplenumber;
    }
    public void setPeoplenumber(String peoplenumber) {
    this.peoplenumber = peoplenumber;
    }
    public String getAuthor() {
    return author;
    }
    public void setAuthor(String author) {
    this.author = author;
    }
    public String getChubanshe() {
    return chubanshe;
    }
    public void setChubanshe(String chubanshe) {
    this.chubanshe = chubanshe;
    }
    public Book(String book) {
    this.name=book;
    }
    public Book(String name,String author,String idc,String peoplenumber,String chubanshe)
    {
    this.author=author;
    this.chubanshe=chubanshe;
    this.idc=idc;
    this.name=name;
    this.peoplenumber=peoplenumber;
    }
    }

    package Bean;

    public class Student {
    private String name;
    private String idc;
    private String sex;
    private String major;
    private String password;
    private String book;
    private String date;
    public String getDate() {
    return date;
    }
    public void setDate(String date) {
    this.date = date;
    }
    public String getBook() {
    return book;
    }
    public void setBook(String book) {
    this.book = book;
    }
    public String getPassword() {
    return password;
    }
    public void setPassword(String password) {
    this.password = password;
    }
    public String getName() {
    return name;
    }
    public void setName(String name) {
    this.name = name;
    }
    public String getIdc() {
    return idc;
    }
    public void setIdc(String idc) {
    this.idc = idc;
    }
    public String getSex() {
    return sex;
    }
    public void setSex(String sex) {
    this.sex = sex;
    }
    public String getMajor() {
    return major;
    }
    public void setMajor(String major) {
    this.major = major;
    }
    public Student()
    {

    }
    public Student(String name,String idc,String major)
    {
    this.major=major;
    this.name=name;
    this.idc=idc;
    }
    public Student(String name,String major)
    {
    this.major=major;
    this.name=name;
    }
    public Student(String name,String idc,String password,String major,String sex)
    {
    this.idc=idc;
    this.password=password;
    this.major=major;
    this.name=name;
    this.sex=sex;
    }
    public Student(String name,String idc,String book,String major,String sex,String date)
    {
    this.idc=idc;
    this.book=book;
    this.major=major;
    this.name=name;
    this.sex=sex;
    this.date=date;
    }
    public Student(String name,String idc,String sex,String major)
    {
    this.idc=idc;
    this.major=major;
    this.name=name;
    this.sex=sex;
    }
    }

    package Dao;

    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;

    import Bean.Beanid;
    import DBUitl.DBUtil;

    public class Dao {
    //



    public static boolean id(String id,String pwd) {
    boolean f = false;
    String sql = "select * from denglu where idc = '" + id + "' and password = '"+ pwd +"'";
    //
    Connection conn = DBUtil.getConn();
    Statement state = null;
    ResultSet rs = null;
    try {
    state = conn.createStatement();
    rs = state.executeQuery(sql);
    if (rs.next()) {
    f = true;
    }
    } catch (SQLException e) {
    e.printStackTrace();
    } finally {
    DBUtil.close(rs, state, conn);
    }
    return f;
    }
    }

    package Dao;

    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import java.util.Date;

    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.ArrayList;
    import java.util.List;
    import java.text.*;
    import Bean.*;
    import DBUitl.DBUtil;

    public class TSDao {
    //

    public static String change(String date)
    {
    Date parse = null;
    String dateString = "";
    try {
    parse = new SimpleDateFormat("yyyyMMdd").parse(date);
    dateString = new SimpleDateFormat("yyyy-MM-dd").format(parse);
    } catch (ParseException e) {
    dateString=null;
    }

    return dateString;
    }

    public static int peoplenumbernow(String name)
    {
    String sql = "select * from chosebook where book like '%" + name + "%'";
    int i=0;
    Connection conn = DBUtil.getConn();
    Statement state = null;
    ResultSet rs = null;

    try {
    state = conn.createStatement();
    rs = state.executeQuery(sql);
    while (rs.next()) {
    i++;
    }
    } catch (SQLException e) {
    e.printStackTrace();
    } finally {
    DBUtil.close(rs, state, conn);
    }

    return i;
    }



    public static boolean addbook(Book book) {
    boolean f = false;
    String sql = "insert into book(name,idc,author,chubanshe,peoplenumber) values('" + book.getName() + "','" + book.getIdc() + "','" + book.getAuthor() + "','" + book.getChubanshe() + "','" + book.getPeoplenumber() + "')";
    //
    Connection conn = DBUtil.getConn();
    Statement state = null;
    int a = 0;
    try {
    state = conn.createStatement();
    a = state.executeUpdate(sql);
    } catch (SQLException e) {
    e.printStackTrace();
    } finally {
    DBUtil.close(state, conn);
    }

    if (a > 0) {
    f = true;
    }
    return f;
    }
    public static boolean addstudent(Student student) {
    boolean f = false;
    String sql = "insert into denglu(name,idc,password,sex,major) values('" + student.getName() + "','" + student.getIdc() + "','" + student.getPassword() + "','" + student.getSex() + "','" + student.getMajor() + "')";
    //
    Connection conn = DBUtil.getConn();
    Statement state = null;
    int a = 0;
    try {
    state = conn.createStatement();
    a = state.executeUpdate(sql);
    } catch (SQLException e) {
    e.printStackTrace();
    } finally {
    DBUtil.close(state, conn);
    }

    if (a > 0) {
    f = true;
    }
    return f;
    }


    public static List<Book> search(String name,String author) {
    String sql = "select * from book where ";

    if (name != "") {
    sql += "name like '%" + name + "%'";
    }
    else if (author != "") {
    sql += "author like '%" + author + "%'";
    }
    else
    {
    }

    List<Book> list = new ArrayList<>();
    Connection conn = DBUtil.getConn();
    Statement state = null;
    ResultSet rs = null;

    try {
    state = conn.createStatement();
    rs = state.executeQuery(sql);
    Book bean = null;
    while (rs.next()) {
    String name2 = rs.getString("name");
    String idc = rs.getString("idc");
    String author2 = rs.getString("author");
    String chubanshe = rs.getString("chubanshe");
    String peoplenumber = rs.getString("peoplenumber");
    bean = new Book(name2,author2,idc,peoplenumber,chubanshe);
    list.add(bean);
    }
    } catch (SQLException e) {
    e.printStackTrace();
    } finally {
    DBUtil.close(rs, state, conn);
    }

    return list;
    }




    public static String getbyid(String name) {
    String sql = "select * from book where name ='" + name + "'";
    Connection conn = DBUtil.getConn();
    Statement state = null;
    ResultSet rs = null;
    String number = new String();
    try {
    state = conn.createStatement();
    rs = state.executeQuery(sql);
    while (rs.next()) {
    number = rs.getString("peoplenumber");
    }
    } catch (Exception e) {
    e.printStackTrace();
    } finally {
    DBUtil.close(rs, state, conn);
    }

    return number;
    }


    public static List<Book> getbyid2(String name) {
    String sql = "select * from book where name ='" + name + "'";
    Connection conn = DBUtil.getConn();
    Statement state = null;
    ResultSet rs = null;
    Book bean =null;
    List<Book> list = new ArrayList<>();
    try {
    state = conn.createStatement();
    rs = state.executeQuery(sql);
    while (rs.next()) {
    String name2 = rs.getString("name");
    String idc = rs.getString("idc");
    String author2 = rs.getString("author");
    String chubanshe = rs.getString("chubanshe");
    String peoplenumber = rs.getString("peoplenumber");
    bean = new Book(name2,author2,idc,peoplenumber,chubanshe);
    list.add(bean);
    }
    } catch (Exception e) {
    e.printStackTrace();
    } finally {
    DBUtil.close(rs, state, conn);
    }

    return list;
    }

    public static Book getbyid3(String name) {
    String sql = "select * from book where name ='" + name + "'";
    Connection conn = DBUtil.getConn();
    Statement state = null;
    ResultSet rs = null;
    Book bean =null;
    try {
    state = conn.createStatement();
    rs = state.executeQuery(sql);
    while (rs.next()) {
    String name2 = rs.getString("name");
    String idc = rs.getString("idc");
    String author2 = rs.getString("author");
    String chubanshe = rs.getString("chubanshe");
    String peoplenumber = rs.getString("peoplenumber");
    bean = new Book(name2,author2,idc,peoplenumber,chubanshe);
    }
    } catch (Exception e) {
    e.printStackTrace();
    } finally {
    DBUtil.close(rs, state, conn);
    }

    return bean;
    }



    public static Student getbyid4(String id) {
    String sql = "select * from chosestudent where id ='" + id + "'";
    Connection conn = DBUtil.getConn();
    Statement state = null;
    ResultSet rs = null;
    Student bean =null;
    try {
    state = conn.createStatement();
    rs = state.executeQuery(sql);
    while (rs.next()) {
    String name2 = rs.getString("name");
    String idc = rs.getString("idc");
    String sex = rs.getString("sex");
    String major = rs.getString("major");
    String book = rs.getString("book");
    String date = rs.getString("date");
    bean = new Student(name2,idc,book,major,sex,date);
    }
    } catch (Exception e) {
    e.printStackTrace();
    } finally {
    DBUtil.close(rs, state, conn);
    }

    return bean;
    }



    public static Student getbyid5(String id) {
    String sql = "select * from chosestudent where id ='" + id + "'";
    Connection conn = DBUtil.getConn();
    Statement state = null;
    ResultSet rs = null;
    Student bean =new Student();
    try {
    state = conn.createStatement();
    rs = state.executeQuery(sql);
    while (rs.next()) {
    String book = rs.getString("book");
    String date = rs.getString("date");
    bean.setBook(book);
    bean.setDate(date);
    bean.setName(id);
    }
    } catch (Exception e) {
    e.printStackTrace();
    } finally {
    DBUtil.close(rs, state, conn);
    }

    return bean;
    }




    public static List<Book> booklist() {
    String sql = "select * from book";
    List<Book> list = new ArrayList<>();
    Connection conn = DBUtil.getConn();
    Statement state = null;
    ResultSet rs = null;

    try {
    state = conn.createStatement();
    rs = state.executeQuery(sql);
    Book bean = null;
    while (rs.next()) {
    String name = rs.getString("name");
    String author = rs.getString("author");
    String idc = rs.getString("idc");
    String peoplenumber = rs.getString("peoplenumber");
    String chubanshe = rs.getString("chubanshe");
    bean = new Book(name,author,idc,peoplenumber,chubanshe);
    list.add(bean);
    }
    } catch (SQLException e) {
    e.printStackTrace();
    } finally {
    DBUtil.close(rs, state, conn);
    }

    return list;
    }


    public static List<Book> booklist2(String idc) throws Exception {
    String sql = "select * from chosestudent where idc like '%" + idc + "%'";
    List<Book> list = new ArrayList<>();
    Connection conn = DBUtil.getConn();
    Statement state = null;
    ResultSet rs = null;

    try {
    state = conn.createStatement();
    rs = state.executeQuery(sql);
    while (rs.next()) {
    String date = rs.getString("date");
    String book = rs.getString("book");
    int renewalsdata = 3;
    SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
    Date sd=df.parse(date);
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(sd);
    int month = calendar.get(Calendar.MONTH) + 1;
    if(month>9)
    {
    calendar.add(Calendar.YEAR, 1);
    }
    calendar.add(Calendar.MONTH, renewalsdata);
    String NOW = df.format(new Date());
    Integer i=NOW.compareTo(df.format(calendar.getTime()));
    if(i>0)
    {
    list.add(getbyid3(book));
    }
    }
    } catch (SQLException e) {
    e.printStackTrace();
    } finally {
    DBUtil.close(rs, state, conn);
    }

    return list;
    }



    public static List<Student> booklist4(String idc) throws Exception {
    String sql = "select * from chosestudent where idc like '%" + idc + "%'";
    List<Student> list = new ArrayList<>();
    Connection conn = DBUtil.getConn();
    Statement state = null;
    ResultSet rs = null;

    try {
    state = conn.createStatement();
    rs = state.executeQuery(sql);
    while (rs.next()) {
    String id = rs.getString("id");
    list.add(getbyid5(id));
    }
    }
    catch (SQLException e) {
    e.printStackTrace();
    } finally {
    DBUtil.close(rs, state, conn);
    }

    return list;
    }




    public static List<Student> booklist3() throws Exception {
    String sql = "select * from chosestudent";
    List<Student> list = new ArrayList<>();
    Connection conn = DBUtil.getConn();
    Statement state = null;
    ResultSet rs = null;

    try {
    state = conn.createStatement();
    rs = state.executeQuery(sql);
    while (rs.next()) {
    String date = rs.getString("date");
    String id = rs.getString("id");
    int renewalsdata = 3;
    SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
    Date sd=df.parse(date);
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(sd);
    int month = calendar.get(Calendar.MONTH) + 1;
    if(month>9)
    {
    calendar.add(Calendar.YEAR, 1);
    }
    calendar.add(Calendar.MONTH, renewalsdata);
    String NOW = df.format(new Date());
    Integer i=NOW.compareTo(df.format(calendar.getTime()));
    if(i>0)
    {
    list.add(getbyid4(id));
    }
    }
    } catch (SQLException e) {
    e.printStackTrace();
    } finally {
    DBUtil.close(rs, state, conn);
    }

    return list;
    }



    public static boolean chosebook(String book,String studentidc) {
    boolean f = false;
    String sql = "select * from denglu where idc like '%" + studentidc + "%'";
    Connection conn = DBUtil.getConn();
    Statement state = null;
    ResultSet rs = null;
    Student student = null;
    try {
    state = conn.createStatement();
    rs = state.executeQuery(sql);
    while (rs.next()) {
    String name = rs.getString("name");
    String sex = rs.getString("sex");
    String major = rs.getString("major");
    student = new Student(name,studentidc,sex,major);
    }
    } catch (SQLException e) {
    e.printStackTrace();
    } finally {
    DBUtil.close(rs, state, conn);
    }
    java.sql.Date time= new java.sql.Date(new Date().getTime());
    String sql1 = "insert into chosestudent(name,idc,major,sex,book,date) values('" + student.getName() + "','" + studentidc + "','" + student.getMajor() + "','" + student.getSex() + "','" + book + "','" + time + "')";
    //
    Connection conn1 = DBUtil.getConn();
    Statement state1 = null;
    int a = 0;
    try {
    state1 = conn1.createStatement();
    a = state1.executeUpdate(sql1);
    } catch (SQLException e) {
    e.printStackTrace();
    } finally {
    DBUtil.close(state1, conn1);
    }

    if (a > 0) {
    f = true;
    }
    return f;
    }



    public static boolean delete(String id) {
    boolean f = false;
    String sql = "delete from chosestudent where id='" + id + "'";
    //
    Connection conn = DBUtil.getConn();
    Statement state = null;
    int a = 0;
    try {
    state = conn.createStatement();
    a = state.executeUpdate(sql);
    } catch (SQLException e) {
    e.printStackTrace();
    } finally {
    DBUtil.close(state, conn);
    }

    if (a > 0) {
    f = true;
    }
    return f;
    }



    public static List<Student> chosecoursestudentlist(String course) {
    String sql = "select * from chosestudent where course like '%" + course + "%'";
    List<Student> list = new ArrayList<>();
    Connection conn = DBUtil.getConn();
    Statement state = null;
    ResultSet rs = null;

    try {
    state = conn.createStatement();
    rs = state.executeQuery(sql);
    Student bean = null;
    while (rs.next()) {
    String name1 = rs.getString("name");
    String idc = rs.getString("idc");
    String class1 = rs.getString("class");
    String major = rs.getString("major");
    bean = new Student(name1,idc,class1,major);
    list.add(bean);
    }
    } catch (SQLException e) {
    e.printStackTrace();
    } finally {
    DBUtil.close(rs, state, conn);
    }

    return list;
    }

    }

    package DBUitl;

    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    public class DBUtil {

    public static String db_url = "jdbc:mysql://localhost:3306/tu_shu?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone = GMT&allowPublicKeyRetrieval=true";
    public static String db_user = "root";
    public static String db_pass = "";

    public static Connection getConn () {
    Connection conn = null;

    try {
    Class.forName("com.mysql.cj.jdbc.Driver");//加载驱动
    conn = DriverManager.getConnection(db_url, db_user, db_pass);
    } catch (Exception e) {
    e.printStackTrace();
    }

    return conn;
    }

    /*10鍏抽棴杩炴帴*/
    public static void close (Statement state, Connection conn) {
    if (state != null) {
    try {
    state.close();
    } catch (SQLException e) {
    e.printStackTrace();
    }
    }

    if (conn != null) {
    try {
    conn.close();
    } catch (SQLException e) {
    e.printStackTrace();
    }
    }
    }

    public static void close (ResultSet rs, Statement state, Connection conn) {
    if (rs != null) {
    try {
    rs.close();
    } catch (SQLException e) {
    e.printStackTrace();
    }
    }

    if (state != null) {
    try {
    state.close();
    } catch (SQLException e) {
    e.printStackTrace();
    }
    }

    if (conn != null) {
    try {
    conn.close();
    } catch (SQLException e) {
    e.printStackTrace();
    }
    }
    }

    public static void main(String[] args) throws SQLException {
    }
    }

    package Servlet;

    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.Cookie;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    import Dao.Dao;
    import Bean.Beanid;

    @WebServlet("/Servlet")
    public class Servlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
    * @see HttpServlet#HttpServlet()
    */



    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    request.setCharacterEncoding("utf-8");
    denglu(request, response);
    }
    private void denglu(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    request.setCharacterEncoding("utf-8");
    String jiese = request.getParameter("jiese");
    String idc = request.getParameter("id");
    String password = request.getParameter("password");
    Beanid Beanid = new Beanid(jiese,idc,password);
    if(Dao.id(idc,password)) {
    if((Beanid.getJiese()).equals("1")){
    request.setAttribute("message", "登录成功");
    Cookie cookie = new Cookie("id",idc);
    response.addCookie(cookie);
    response.sendRedirect("menu1.jsp");
    }
    else if((Beanid.getJiese()).equals("2"))
    {
    request.setAttribute("message", "登录成功");
    Cookie cookie = new Cookie("id",idc);
    response.addCookie(cookie);
    response.sendRedirect("menu2.jsp");
    }
    else
    {
    request.setAttribute("message", "登录失败");
    request.getRequestDispatcher("begin.jsp").forward(request,response);
    }
    } else {
    request.setAttribute("message", "登录失败");
    request.getRequestDispatcher("begin.jsp").forward(request,response);
    }

    }



    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    doGet(request, response);
    }


    /**
    * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
    */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    response.getWriter().append("Served at: ").append(request.getContextPath());
    }

    /**
    * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
    */


    }

    package Servlet;

    import java.io.IOException;
    import java.util.List;

    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    import Dao.TSDao;
    import Bean.*;

    @WebServlet("/TSservlet")
    public class TSservlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
    * @see HttpServlet#HttpServlet()
    */



    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    request.setCharacterEncoding("utf-8");
    String method = request.getParameter("method");
    if ("addbook".equals(method)) {
    addbook(request, response);
    }
    else if ("addstudent".equals(method)) {
    addstudent(request, response);
    }
    else if ("search".equals(method)) {
    search(request, response);
    }
    else if ("chosebook".equals(method)) {
    chosebook(request, response);
    }
    else if ("booklist".equals(method)) {
    booklist(request, response);
    }
    else if ("booklist1".equals(method)) {
    booklist1(request, response);
    }
    else if ("booklist2".equals(method)) {
    try {
    booklist2(request, response);
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }
    else if ("booklist3".equals(method)) {
    try {
    booklist3(request, response);
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }
    else if ("deletebook".equals(method)) {
    deletebook(request, response);
    }
    else if ("chosebookstudentlist".equals(method)) {
    try {
    chosebookstudentlist(request, response);
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }

    }
    private void addbook(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    request.setCharacterEncoding("utf-8");
    String name = request.getParameter("name");
    String chubanshe = request.getParameter("chubanshe");
    String idc = request.getParameter("idc");
    String author = request.getParameter("author");
    String peoplenumber = request.getParameter("peoplenumber");
    Book book = new Book(name,author,idc,peoplenumber,chubanshe);
    if(TSDao.addbook(book)) {
    request.setAttribute("message", "添加图书信息成功");
    request.getRequestDispatcher("menu1.jsp").forward(request,response);
    } else {
    request.setAttribute("message", "添加图书信息失败");
    request.getRequestDispatcher("menu1.jsp").forward(request,response);
    }

    }


    private void addstudent(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    request.setCharacterEncoding("utf-8");
    String name = request.getParameter("name");
    String idc = request.getParameter("idc");
    String sex = request.getParameter("sex");
    String password = request.getParameter("password");
    String major = request.getParameter("major");
    Student student = new Student(name,idc,password,major,sex);
    if(TSDao.addstudent(student)) {
    request.setAttribute("message", "添加学生信息成功");
    request.getRequestDispatcher("menu1.jsp").forward(request,response);
    } else {
    request.setAttribute("message", "添加学生信息失败");
    request.getRequestDispatcher("menu1.jsp").forward(request,response);
    }

    }




    private void search(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
    req.setCharacterEncoding("utf-8");
    String name = req.getParameter("name");
    String author = req.getParameter("author");

    List<Book> books = TSDao.search(name,author);
    req.setAttribute("books", books);
    req.getRequestDispatcher("list.jsp").forward(req,resp);
    }


    private void chosebook(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
    req.setCharacterEncoding("utf-8");
    String name = req.getParameter("name");
    String studentidc = req.getParameter("studentidc");
    int i = TSDao.peoplenumbernow(name);
    String number = TSDao.getbyid(name);
    if(i<Integer.parseInt(number))
    {
    if(TSDao.chosebook(name, studentidc))
    {
    req.setAttribute("message", "选课成功!");
    req.getRequestDispatcher("menu2.jsp").forward(req,resp);
    }
    else
    {
    req.setAttribute("message", "选课失败!");
    req.getRequestDispatcher("menu2.jsp").forward(req,resp);
    }
    }
    else
    {
    req.setAttribute("message", "选课失败!");
    req.getRequestDispatcher("menu2.jsp").forward(req,resp);
    }
    }








    private void booklist(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
    req.setCharacterEncoding("utf-8");
    List<Book> books = TSDao.booklist();
    req.setAttribute("books", books);
    req.getRequestDispatcher("booklist.jsp").forward(req,resp);
    }


    private void booklist1(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
    req.setCharacterEncoding("utf-8");
    List<Book> books = TSDao.booklist();
    req.setAttribute("books", books);
    req.getRequestDispatcher("booklist1.jsp").forward(req,resp);
    }



    private void booklist2(HttpServletRequest req, HttpServletResponse resp) throws Exception{
    req.setCharacterEncoding("utf-8");
    String idc = req.getParameter("idc");
    List<Book> books = TSDao.booklist2(idc);
    req.setAttribute("books", books);
    req.getRequestDispatcher("booklist2.jsp").forward(req,resp);
    }


    private void booklist3(HttpServletRequest req, HttpServletResponse resp) throws Exception{
    req.setCharacterEncoding("utf-8");
    String idc = req.getParameter("idc");
    List<Student> Students = TSDao.booklist4(idc);
    req.setAttribute("Students", Students);
    req.getRequestDispatcher("booklist3.jsp").forward(req,resp);
    }

    private void deletebook(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
    req.setCharacterEncoding("utf-8");
    String id = req.getParameter("id");
    if(TSDao.delete(id)) {
    req.setAttribute("message", "还书成功!");
    req.getRequestDispatcher("booklist3.jsp").forward(req,resp);
    }
    else
    {
    req.setAttribute("message", "还书失败!");
    req.getRequestDispatcher("menu2.jsp").forward(req,resp);
    }
    }

    private void chosebookstudentlist(HttpServletRequest req, HttpServletResponse resp) throws Exception{
    req.setCharacterEncoding("utf-8");
    List<Student> Students = TSDao.booklist3();
    req.setAttribute("Students", Students);
    req.getRequestDispatcher("chosebooksstudentlist.jsp").forward(req,resp);
    }


    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    doGet(request, response);
    }


    /**
    * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
    */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    response.getWriter().append("Served at: ").append(request.getContextPath());
    }

    /**
    * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
    */


    }

    <%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Insert title here</title>
    </head>
    <body>
    <%! String id;%>
    <%
    Cookie[] cookies = request.getCookies();
    for(Cookie cookie :cookies)
    {
    if(cookie.getName().equals("id"))
    {
    id = cookie.getValue();
    }
    }
    %>
    <%
    Object message = request.getAttribute("message");
    if(message!=null && !"".equals(message)){

    %>
    <script type="text/javascript">
    alert("<%=request.getAttribute("message")%>");
    </script>
    <%} %>
    <h1 style="color: black;">添加图书信息</h1>
    <h2 style="color: black;">欢迎工号为<%=id%>的管理员进行图书信息添加!</h2>
    <a href="menu1.jsp">返回主页</a>
    <form name = "form1" action="TSservlet?method=addbook" method="post" onsubmit="return checkForm()">
    <div class="a">
    图书名称:<input type="text" id="name" name="name" />
    </div>
    <div class="a">
    图书编号:<input type="text" id="idc" name="idc" />
    </div>
    <div class="a">
    作者:<input type="text" id="author" name="author" />
    </div>
    <div class="a">
    出版社名称:<input type="text" id="chubanshe" name="chubanshe" />
    </div>
    <div class="a">
    可借阅数量:<input type="text" id="peoplenumber" name="peoplenumber" />
    </div>
    <div class="a">
    <button type=submit >提交</button>
    </div>
    </form>
    <script type="text/javascript">
    function checkForm(){
    var chubanshe = document.getElementById("chubanshe").value;
    var name = document.getElementById("name").value;
    var author = document.getElementById("author").value;
    var idc = document.getElementById("idc").value;
    var peoplenumber = document.getElementById("peoplenumber").value;
    if(idc == '') {
    alert('编号为空');
    return false;
    }if(name == ''|| name == null) {
    alert('书名为空');
    return false;
    }if(author == ''|| teacher == null) {
    alert('作者为空');
    return false;
    }if(chubanshe == ''|| chubanshe == null) {
    alert('出版社为空');
    return false;
    }if(peoplenumber == ''|| peoplenumber == null) {
    alert('可借阅人数');
    return false;
    }
    return true;
    }
    </script>

    </body>
    </html>

    <%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Insert title here</title>
    </head>
    <body>
    <%! String id;%>
    <%
    Cookie[] cookies = request.getCookies();
    for(Cookie cookie :cookies)
    {
    if(cookie.getName().equals("id"))
    {
    id = cookie.getValue();
    }
    }
    %>
    <%
    Object message = request.getAttribute("message");
    if(message!=null && !"".equals(message)){

    %>
    <script type="text/javascript">
    alert("<%=request.getAttribute("message")%>");
    </script>
    <%} %>
    <h1 style="color: black;">添加学生信息</h1>
    <h2 style="color: black;">欢迎工号为<%=id%>的管理员进行学生信息添加!</h2>
    <a href="menu1.jsp">返回主页</a>
    <form name = "form1" action="TSservlet?method=addstudent" method="post" onsubmit="return checkForm()">
    <div class="a">
    学生姓名:<input type="text" id="name" name="name" />
    </div>
    <div class="a">
    学号:<input type="text" id="idc" name="idc" />
    </div>
    <div class="a">
    密码:<input type="text" id="password" name="password" />
    </div>
    <div class="a">
    性别:
    男<input type="radio" name="sex" value="男" checked="checked">
    女<input type="radio" name="sex" value="女" >
    </div>
    <div class="a">
    所在专业:<input type="text" id="major" name="major" />
    </div>
    <div class="a">
    <button type=submit class="btn" >提交</button>
    </div>
    </form>
    <script type="text/javascript">
    function checkForm(){
    var name = document.getElementById("name").value;
    var major = document.getElementById("major").value;
    var idc = document.getElementById("idc").value;
    var password = document.getElementById("password").value;
    if(idc == '') {
    alert('学号为空');
    return false;
    }if(password == '') {
    alert('密码为空');
    return false;
    }if(name == ''|| name == null) {
    alert('姓名为空');
    return false;
    }if(major == ''|| major == null) {
    alert('专业为空');
    return false;
    }
    return true;
    }
    </script>
    </body>
    </html>

    <%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="texe/html; charset=utf-8">
    <title>Insert title here</title>
    <style type="text/css">
    body{
    font-size:12px;
    margin:0px auto;
    height:auto;
    100%;
    background-image: url("../images/811727.jpg");/*插入背景图片*/
    color:#FFFFFF;
    background-size:cover;
    text-align:center;
    font-family:Arial,Helvetica,sans-serif;
    }
    h1{
    font-family:'Times New Roman', Times, serif;
    font-size:50px;
    font-weight:bold;
    text-align:center;
    color:#FFFFFF;
    }
    p{
    text-indent:2em;
    text-align:center;
    padding-top:8px;
    }

    #line{
    display:inline-block;
    310px;
    border-top:1px solid #CCCCCC;
    vertical-align:5px;
    margin-left:10px;
    margin-right:10px;
    }
    #header{
    height:100px;
    auto;
    margin-right:auto;
    margin-left:auto;
    padding:0px;
    text-align:center;
    background-repeat:no-repeat;
    }
    #navigator{ /*定义一个导航栏的长盒子*/
    margin-top:5px;
    display: inline-block;
    font-size:21px;
    list-style-type:none; /*让navigator这个大盒子下面的小盒子li列表样式不显示,这对于标准浏览器很重要*/
    }
    #navigator li{
    float:left; 让li这些小盒子左对齐*/
    }
    #navigator li a{
    color:#FFFFFF;
    text-decoration:none; /*让li盒子里面的链接样式没有下划线*/
    padding-top:4px;
    display:block /*让li里面的链接以块状呈现,就像一个按钮,而不必一定要点中间的链接文字才起作用*/
    text-align:center;
    margin-left:64px;
    }
    #navigator li a:hover{
    background-color:#808080; /*鼠标指针移到链接盒子上面改变盒子的背景色*/
    color:#FFFFFF;
    }
    #content{
    auto;
    padding:5px 0px 0px 0px;
    }
    #content td{
    padding:8px;
    }
    #footer{
    clear:both;
    auto;
    margin-right:auto;
    margin-left:auto;
    line-height:2em;
    text-align:center;
    padding:0px;
    }
    #username,#password{
    250px;
    height:31px;
    border:1px solid #A6A6A6;
    border-radius:5px;
    padding-left:10px;
    }
    #checkcode{
    164px;
    height:31px;
    border:1px solid #A6A6A6;
    border-radius:5px;
    padding-left:10px;
    }
    #img_check{
    height:32px;
    80px;
    vertical-align:middle;
    border:1px solid #A6A6A6;
    border-radius:5px;
    }
    #signin{
    150px;
    height:40px;
    background-color:#FFD026;
    border:1px solid #FFD026;
    }
    *{
    margin:0px;
    }
    </style>
    </head>
    <body>
    <%
    Object message = request.getAttribute("message");
    if(message!=null && !"".equals(message)){
    %>
    <script type="text/javascript">
    alert("<%=request.getAttribute("message")%>");
    </script>
    <%} %>
    <div id="header">
    <h1>用户登陆</h1>
    </div>
    <div id="content">
    <form name = "form1" action="Servlet" method="post" onsubmit="return check_submit()">
    <table border="0" cellpadding="0" cellspacing="0" style="100%;height: 100%;">
    <tr>
    <td style="100%" align="center" valign="middle">
    <table style="margin: auto;">
    <div id="line"></div><font size="5">登录</font><div id="line"></div>
    <br><br>
    <tr>
    <td align="left"><label for="username">用户名</label></td>
    <td align="right"><input type="text" name="username" id="username" placeholder="请输入6-10位字母、数字或下划线"/></td>
    </tr>
    <tr>
    <td align="left"><label for="password">密码</label></td>
    <td align="right"><input type="password" name="password" id="password" placeholder="请输入至少6位字母、数字"/></td>
    </tr>
    <tr>
    <td align="left"><label for="checkcode">验证码</label></td>
    <td align="right"><input type="text" name="checkcode" id="checkcode" placeholder="请输入验证码"/>
    <img id="img_check" src="img.jpg"></td>
    </tr>
    <tr>
    <td colspan="2" align="center"><input type="submit" id="signin" value="登录"/></td>
    </tr>
    <tr>
    <td colspan="2" align="right"><a href="#" style="color: #FFFFFF">忘记密码?</a></td></tr>
    </table>
    </td>
    </tr>
    </table>
    </form>
    </div>
    <div id="footer">
    <p>关于 广告服务 | 客服中心 | QQ留言 | 网站管理 | 会员登录 | 隐私政策 | 法律信息</p>
    <p>Copyright @Spiderman出品</p>
    </div>
    <script type="text/javascript">
    /*
    表单验证
    */
    var flag = true; // flag 如果为true(即用户名合法)就允许表单提交, 如果为false(即用户名不合法)阻止提交
    function focus_pass()
    {
    var nameObj = document.getElementById("result1");
    nameObj.innerHTML = "由六位字符和数字组成";
    nameObj.style.color="#999";
    }
    function blur_pass()
    {
    var nameObj = document.getElementById("result1");
    // 判断用户名是否合法
    var str2 = check_user_pass(document.form1.password.value);
    nameObj.style.color="red";
    if ("密码合法" == str2)
    {
    flag = true;
    nameObj.innerHTML = str2;
    }
    else
    {
    nameObj.innerHTML = str2;
    }
    }

    function check_user_pass(str)
    { var str2 = "密码合法";
    if ("" == str)
    {
    str2 = "密码为空";
    return str2;
    }
    else if (str.length!=6)
    {
    str2 = "用户名应是六位组成";
    return str2;
    }
    else if (!check_word(str))
    {
    str2 = "未含有英文字符";
    return str2;
    }

    return str2;


    }

    function focus_id()
    {
    var nameObj = document.getElementById("result");
    nameObj.innerHTML = "由六到十二英文字符和数字组成";
    nameObj.style.color="#999";
    }
    function blur_id()
    {
    var nameObj = document.getElementById("result");
    // 判断用户名是否合法
    var str2 = check_user_id(document.form1.id.value);
    nameObj.style.color="red";
    if ("用户名合法" == str2)
    {
    flag = true;
    nameObj.innerHTML = str2;
    }
    else
    {
    nameObj.innerHTML = str2;
    }
    }

    function check_user_id(str)
    {
    var str2 = "用户名合法";
    if ("" == str)
    {
    str2 = "用户名号为空";
    return str2;
    }
    else if ((str.length<=4)||(str.length>=12))
    {
    str2 = "用户名应是六到十二位组成";
    return str2;
    }
    else if (!check_word(str))
    {
    str2 = "未含有英文字符";
    return str2;
    }
    else if(!check_firstword(str))
    {
    str2 = "必须以英文字母开头";
    return str2;
    }
    return str2;
    }


    function check_firstword(str)
    { var arr = ["a", "b", "c", "d", "e", "f", "g", "h","i","j", "k", "l", "m", "n", "o", "p", "q","r", "s", "t", "u", "v", "w", "x", "y","z","A", "B", "C", "D", "E", "F", "G", "H","I","J", "K", "L", "M", "N", "O", "P", "Q","R","S", "T", "U", "V", "W", "X", "Y", "Z"];
    for (var i = 0; i < arr.length; i++)
    {
    if (arr[i] == str.charAt(0))
    {
    return true;
    }
    }
    return false;
    }


    function check_word(str)
    { var arr = ["a", "b", "c", "d", "e", "f", "g", "h","i","j", "k", "l", "m", "n", "o", "p", "q","r", "s", "t", "u", "v", "w", "x", "y","z","A", "B", "C", "D", "E", "F", "G", "H","I","J", "K", "L", "M", "N", "O", "P", "Q","R","S", "T", "U", "V", "W", "X", "Y", "Z"];
    for (var i = 0; i < arr.length; i++)
    {
    for (var j = 0; j < str.length; j++)
    {
    if (arr[i] == str.charAt(j))
    {
    return true;
    }
    }
    }
    return false;
    }

    // 验证用户名是否含有特殊字符
    function check_other_char(str)
    {
    var arr = ["&", "\", "/", "*", ">", "<", "@", "!"];
    for (var i = 0; i < arr.length; i++)
    {
    for (var j = 0; j < str.length; j++)
    {
    if (arr[i] == str.charAt(j))
    {
    return true;
    }
    }
    }
    return false;
    }*/
    // 根据验证结果确认是否提交
    function check_submit()
    {
    if (flag == false)
    {
    return false;
    }
    return true;
    }
    </script>
    </head>
    </body>
    <script>
    var show_num = [];
    draw(show_num);
    function dj(){
    draw(show_num);
    }
    function sublim(){
    var val=document.getElementById("text").value;
    var num = show_num.join("");
    if(val==''){
    alert('请输入验证码!');
    flag=false;
    }else if(val == num){
    alert('提交成功!');
    document.getElementById(".input-val").val('');
    draw(show_num);
    }else{
    alert('验证码错误! 你输入的是: '+val+" 正确的是: "+num+' 请重新输入!');
    document.getElementById("text").value='';
    draw(show_num);
    flag=false;
    }



    }
    function draw(show_num) {
    var canvas_width=document.getElementById('canvas').clientWidth;
    var canvas_height=document.getElementById('canvas').clientHeight;
    var canvas = document.getElementById("canvas");//获取到canvas的对象,演员
    var context = canvas.getContext("2d");//获取到canvas画图的环境,演员表演的舞台
    canvas.width = canvas_width;
    canvas.height = canvas_height;
    var sCode = "1,2,3,4,5,6,7,8,9,0,q,w,e,r,t,y,u,i,o,p,a,s,d,f,g,h,j,k,l,z,x,c,v,b,n,m";
    var aCode = sCode.split(",");
    var aLength = aCode.length;//获取到数组的长度

    for (var i = 0; i <= 3; i++) {
    var j = Math.floor(Math.random() * aLength);//获取到随机的索引值
    var deg = Math.random() * 30 * Math.PI / 180;//产生0~30
    var txt = aCode[j];//得到随机的一个内容
    show_num[i] = txt;
    var x = 10 + i * 20;//文字在canvas上的x坐标
    var y = 20 + Math.random() * 8;//文字在canvas上的y坐标
    context.font = "bold 23px 微软雅黑";

    context.translate(x, y);
    context.rotate(deg);

    context.fillStyle = randomColor();
    context.fillText(txt, 0, 0);

    context.rotate(-deg);
    context.translate(-x, -y);
    }
    for (var i = 0; i <= 5; i++) { //验证码上显示线条
    context.strokeStyle = randomColor();
    context.beginPath();
    context.moveTo(Math.random() * canvas_width, Math.random() * canvas_height);
    context.lineTo(Math.random() * canvas_width, Math.random() * canvas_height);
    context.stroke();
    }
    for (var i = 0; i <= 30; i++) { //验证码上显示小点
    context.strokeStyle = randomColor();
    context.beginPath();
    var x = Math.random() * canvas_width;
    var y = Math.random() * canvas_height;
    context.moveTo(x, y);
    context.lineTo(x + 1, y + 1);
    context.stroke();
    }
    }
    function randomColor() {//得到随机的颜色值
    var r = Math.floor(Math.random() * 256);
    var g = Math.floor(Math.random() * 256);
    var b = Math.floor(Math.random() * 256);
    return "rgb(" + r + "," + g + "," + b + ")";
    }
    </script>
    </html>

    <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Insert title here</title>

    </head>
    <body>
    <%
    Object message = request.getAttribute("message");
    if(message!=null && !"".equals(message)){

    %>
    <script type="text/javascript">
    alert("<%=request.getAttribute("message")%>");
    </script>
    <%} %>
    <div align="center">
    <h1 style="color: black;">课程信息列表</h1>
    <a href="menu2.jsp">返回主页</a>
    <table class="tb">
    <tr>
    <td>图书编码</td>
    <td>图书名称</td>
    <td>作者</td>
    <td>出版社</td>
    <td>可借阅名额</td>
    </tr>
    <c:forEach items="${books}" var="item">
    <tr>
    <td>${item.idc}</td>
    <td>${item.name}</td>
    <td>${item.author}</td>
    <td>${item.chubanshe}</td>
    <td>${item.peoplenumber}</td>
    </tr>
    </c:forEach>
    </table>
    </div>
    </body>
    </html>

    <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Insert title here</title>

    </head>
    <body>
    <%! String id;%>
    <%
    Cookie[] cookies = request.getCookies();
    for(Cookie cookie :cookies)
    {
    if(cookie.getName().equals("id"))
    {
    id = cookie.getValue();
    }
    }
    %>
    <%
    Object message = request.getAttribute("message");
    if(message!=null && !"".equals(message)){

    %>
    <script type="text/javascript">
    alert("<%=request.getAttribute("message")%>");
    </script>
    <%} %>
    <div align="center">
    <h1 style="color: black;">课程信息列表</h1>
    <a href="menu2.jsp">返回主页</a>
    <table class="tb">
    <tr>
    <td>图书编码</td>
    <td>图书名称</td>
    <td>作者</td>
    <td>出版社</td>
    <td>可借阅名额</td>
    </tr>
    <c:forEach items="${books}" var="item">
    <tr>
    <td>${item.idc}</td>
    <td>${item.name}</td>
    <td>${item.author}</td>
    <td>${item.chubanshe}</td>
    <td>${item.peoplenumber}</td>
    <td><a href="TSservlet?method=chosebook&name=${item.name}&studentidc=<%=id%>">借阅</a></td>
    </tr>
    </c:forEach>
    </table>
    </div>
    </body>
    </html>

    <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Insert title here</title>

    </head>
    <body>
    <%! String id;%>
    <%
    Cookie[] cookies = request.getCookies();
    for(Cookie cookie :cookies)
    {
    if(cookie.getName().equals("id"))
    {
    id = cookie.getValue();
    }
    }
    %>
    <%
    Object message = request.getAttribute("message");
    if(message!=null && !"".equals(message)){

    %>
    <script type="text/javascript">
    alert("<%=request.getAttribute("message")%>");
    </script>
    <%} %>
    <div align="center">
    <h1 style="color: black;">图书信息列表</h1>
    <a href="menu2.jsp">返回主页</a>
    <table class="tb">
    <tr>
    <td>图书编码</td>
    <td>图书名称</td>
    <td>作者</td>
    <td>出版社</td>
    <td>可借阅名额</td>
    </tr>
    <c:forEach items="${books}" var="item">
    <tr>
    <td>${item.idc}</td>
    <td>${item.name}</td>
    <td>${item.author}</td>
    <td>${item.chubanshe}</td>
    <td>${item.peoplenumber}</td>
    </tr>
    </c:forEach>
    </table>
    </div>
    </body>
    </html>

    <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Insert title here</title>

    </head>
    <body>
    <%! String id;%>
    <%
    Cookie[] cookies = request.getCookies();
    for(Cookie cookie :cookies)
    {
    if(cookie.getName().equals("id"))
    {
    id = cookie.getValue();
    }
    }
    %>
    <%
    Object message = request.getAttribute("message");
    if(message!=null && !"".equals(message)){

    %>
    <script type="text/javascript">
    alert("<%=request.getAttribute("message")%>");
    </script>
    <%} %>
    <div align="center">
    <h1 style="color: black;">图书信息列表</h1>
    <a href="menu2.jsp">返回主页</a>
    <table class="tb">
    <tr>
    <td>图书名称</td>
    <td>借阅时间</td>
    </tr>
    <c:forEach items="${Students}" var="item">
    <tr>
    <td>${item.book}</td>
    <td>${item.date}</td>
    <td><a href="TSservlet?method=deletebook&id=${item.name}">还书</a></td>
    </tr>
    </c:forEach>
    </table>
    </div>
    </body>
    </html>

    <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Insert title here</title>

    </head>
    <body>
    <%! String id;%>
    <%
    Cookie[] cookies = request.getCookies();
    for(Cookie cookie :cookies)
    {
    if(cookie.getName().equals("id"))
    {
    id = cookie.getValue();
    }
    }
    %>
    <%
    Object message = request.getAttribute("message");
    if(message!=null && !"".equals(message)){

    %>
    <script type="text/javascript">
    alert("<%=request.getAttribute("message")%>");
    </script>
    <%} %>
    <div align="center">
    <h1 style="color: black;">逾期学生信息列表</h1>
    <a href="menu1.jsp">返回主页</a>
    <table class="tb">
    <tr>
    <td>学生姓名</td>
    <td>学号</td>
    <td>性别</td>
    <td>学院</td>
    <td>未归还图书</td>
    <td>借书日期</td>
    </tr>
    <c:forEach items="${Students}" var="item">
    <tr>
    <td>${item.name}</td>
    <td>${item.idc}</td>
    <td>${item.sex}</td>
    <td>${item.major}</td>
    <td>${item.book}</td>
    <td>${item.date}</td>
    </tr>
    </c:forEach>
    </table>
    </div>
    </body>
    </html>

    <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>信息列表</title>

    </head>
    <body>
    <div align="center">
    <h1 style="color: black;">信息列表</h1>
    <a href="menu2.jsp">返回主页</a>
    <table class="tb">
    <tr>
    <td>图书编码</td>
    <td>图书名称</td>
    <td>作者</td>
    <td>出版社</td>
    <td>可借阅数量</td>
    </tr>
    <!-- forEach遍历出adminBeans -->
    <c:forEach items="${books}" var="item" varStatus="status">
    <tr>
    <td>${item.idc}</td>
    <td>${item.name}</td>
    <td>${item.author}</td>
    <td>${item.chubanshe}</td>
    <td>${item.peoplenumber}</td>
    </tr>
    </c:forEach>
    </table>
    </div>
    </body>
    </html>

    <%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Insert title here</title>
    </head>
    <body>
    <%! String id;%>
    <%
    Cookie[] cookies = request.getCookies();
    for(Cookie cookie :cookies)
    {
    if(cookie.getName().equals("id"))
    {
    id = cookie.getValue();
    }
    }
    %>
    <%
    Object message = request.getAttribute("message");
    if(message!=null && !"".equals(message)){

    %>
    <script type="text/javascript">
    alert("<%=request.getAttribute("message")%>");
    </script>
    <%} %>
    <div align="center">
    <div class="a">
    <h2 style="color: black;">欢迎工号为<%=id%>的管理员登录!</h2>
    </div>
    <div class="a">
    <a href="addbook.jsp">添加图书信息</a>
    </div>
    <div class="a">
    <a href="addstudent.jsp">添加读者信息</a>
    </div>
    <div class="a">
    <a href="TSservlet?method=chosebookstudentlist">打印催还书目信息</a>
    </div>
    <div class="a">
    <a href="over.jsp">退出系统</a>
    </div>
    </div>
    </body>
    </html>

    <%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Insert title here</title>
    </head>
    <body>
    <%! String id;%>
    <%
    Cookie[] cookies = request.getCookies();
    for(Cookie cookie :cookies)
    {
    if(cookie.getName().equals("id"))
    {
    id = cookie.getValue();
    }
    }
    %>
    <%
    Object message = request.getAttribute("message");
    if(message!=null && !"".equals(message)){

    %>
    <script type="text/javascript">
    alert("<%=request.getAttribute("message")%>");
    </script>
    <%} %>
    <div align="center">
    <div class="a">
    <h2 style="color: black;">欢迎账号为<%=id%>的读者登录!</h2>

    </div>
    <div class="a">
    <a href="TSservlet?method=booklist">浏览图书信息</a>
    </div>
    <div class="a">
    <a href="search.jsp">查询图书信息</a>
    </div>
    <div class="a">
    <a href="TSservlet?method=booklist1">借阅图书</a>
    </div>
    <div class="a">
    <a href="TSservlet?method=booklist2&idc=<%=id%>">浏览催还书目</a>
    </div>
    <div class="a">
    <a href="TSservlet?method=booklist3&idc=<%=id%>">归还图书</a>
    </div>
    <div class="a">
    <a href="over.jsp">退出系统</a>
    </div>
    </div>
    </body>
    </html>

    <%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Insert title here</title>
    </head>
    <body>
    <form name = "form1" action="TSservlet?method=search" method="post" onsubmit="return checkForm()">
    <%! String id;%>
    <%
    Cookie[] cookies = request.getCookies();
    for(Cookie cookie :cookies)
    {
    if(cookie.getName().equals("id"))
    {
    id = cookie.getValue();
    }
    }
    %>
    <%
    Object message = request.getAttribute("message");
    if(message!=null && !"".equals(message)){

    %>
    <script type="text/javascript">
    alert("<%=request.getAttribute("message")%>");
    </script>
    <%} %>
    <div align="center">
    <div class="a">
    <h1 style="color: black;">添加图书信息</h1>
    </div>
    <div class="a">
    <h2 style="color: black;">欢迎学号为<%=id%>的读者进行图书信息查询!</h2>
    </div>
    <div class="a">
    <a href="menu2.jsp">返回主页</a>
    </div>
    <div class="a">
    图书名称:<input type="text" id="name" name="name" />
    </div>
    <div class="a">
    作者:<input type="text" id="author" name="author" />
    </div>
    <div class="a">
    <button type=submit >提交</button>
    </div>
    </div>
    </form>
    <script type="text/javascript">
    function checkForm(){
    var name = document.getElementById("name").value;
    var author = document.getElementById("author").value;
    if(idc == '') {
    alert('编号为空');
    return false;
    }if(name == ''|| name == null) {
    alert('书名为空');
    return false;
    }
    return true;
    }
    </script>
    </body>
    </html>

  • 相关阅读:
    线段树(区间合并) LA 3989 "Ray, Pass me the dishes!"
    BIT LA 4329 Ping pong
    并查集(路径更新) LA 3027 Corporative Network
    log4j.properties配置详解与实例-全部测试通过
    ActiveMQ入门实例
    activemq安全设置 设置admin的用户名和密码
    Freemarker入门小案例(生成静态网页的其中一种方式)
    maven项目在myeclipse中不出现Maven Dependencies 和maven标识的解决方法
    Mysql,SqlServer,Oracle主键自动增长的设置
    常用SQL语句
  • 原文地址:https://www.cnblogs.com/huangmouren233/p/14083321.html
Copyright © 2011-2022 走看看