Joke Collection Website - Blessing messages - Question: The graduation thesis of the book management system written by JSP.

Question: The graduation thesis of the book management system written by JSP.

1 Preface 4

1. 1 objective 4

1.2 range 4

1.3 Definitions in this system 4

2 data reference 4

3 Design concept 4

3. 1 data layer design 5

Trigger 5 of user_book table

The storage process of renewing books by users 6

Maturity repayment table 7 view

3.2 Data Link Layer Design 8

User Manual Entity Bean Design 9

User Consumer Entity Bean Design 10

User log entity Bean design 1 1

3.3 Data Logic Layer Design 12

Book conversation Bean design 13

User session Bean design 14

Log session Bean design 15

3.4 Network Application Layer Design 15

Check value bean 16

Coding bean 16

JDBCBean bean 16

Ranked beans 16

Install bean 16

SplitPage bean 17

User login bean 17

SearchBook bean 17

Search deadline bean 17

Verify servlet 17

get delete servlet servlet 17

GetBookSubmit servlet 18

GetUserSubmit servlet 18

GetRenewBook servlet 18

GetBorrowBook servlet 18

GetReturnBook servlet 18

4 program architecture 18

4. 1 project organization structure 18

4.2 Division of functional departments 20

4.3 Web Program/Page Design 2 1

4.4 Functions Implemented by the System 22

5 Division of tasks 22

1 preface

1. 1 purpose

This document describes the design of the book management system in detail, mainly to let developers have a deep understanding of the construction and maintenance of this project.

1.2 range

The description in this document only applies to the 1.0 version of the library management system.

1.3 Definitions in this system

The following are the definitions of technical terms used in this manual and the original phrases of foreign initial words:

Definitions and descriptions of terms or abbreviations

BooksManager the name of the system.

Reader system permissions: ordinary readers

BookAdmin system permissions: librarian

User Administrator System Privileges: User Administrator

Super Administrator System Privileges: Super Administrator (System Administrator)

User role of undergraduate system: undergraduate

User role of postgraduate system: postgraduate

Teacher system user role: teacher

2 data reference

Tsinghua University application software platform and core technology lecture notes Gu Ming.

Tsinghua University application software platform and core technology teaching assistant documents: Zhang, Chen Yong, Lin.

Master EJB (second edition)

J2EE application and BEA Web logical server. Trans. Xing Guoqing and others. Electronic Industry Press, April 2002.

Design pattern-the basis of reusable object-oriented software, Erich Gamma et al., Machinery Industry Press.

3 design concept

The system is designed in strict accordance with the four-layer structure, which is divided into data layer (SQL server), data link layer (entity bean), data logic layer (session bean) and network application layer (Java Bean, Java Servlet, Java Server Page).

The four layers are completely independent and can be deployed on four servers, which embodies the idea of distributed application.

Strictly speaking, the function of data layer is to realize basic data storage (all logical processing functions should be handed over to CMP management), but for learning reasons, some logical processing is also used in the database, such as using stored procedures+system-level temporary tables to deal with readers' renewed books, using triggers to prevent unreturned books and users from being cancelled, and using views to detect borrowing records to realize the function of expiration reminder.

The data link layer realizes the connection with the database, and its function is to shield the difference between the database and the platform and realize the bottom independence. This layer uses fuzzy search, multi-table mapping, relationship and other technologies, and throws aggregate objects or remote interface objects to the next layer through the search functions of find find and select method data.

The data logic layer realizes the logical processing of data, such as converting remote interface objects into value objects, converting aggregate objects into value object vectors, and using date classes to complete relatively complex calculations, such as finding records between two specific dates.

The network application layer completes application functions such as page jumping and page display, and there are some additional functions such as picture verification, login verification, grade control, code filtering, paging control, input value detection, book borrowing log printing, system running log recording and system setting. (JDBC is used to implement stored procedures and fuzzy book search functions)

3. 1 data layer design

Database table

Table name function description

User_consumer records all the information of users.

User_book records all the information of this book.

User_logBook records the information of users who use this system, and keeps all book borrowing records, which can be used as system logs and report materials.

Trigger of user_book table

If the book to be cancelled is checked out and not returned, one of the triggers used to roll back the deletion operation.

Create a trigger bookhavelog on dbo.user_book.

Used to delete

be like

declare @ bookISBN varchar(50)

Select @bookISBN=book_ISBN from deleted.

If it exists (select * from user _ logbook where logb _ book _ ISBN = @ bookisbnand.

Logb_backdate is empty)

begin

reverse

return

end

The storage process of users renewing books

Stored procedures are used to realize the logical operation of renewing books for users. According to the current information of users, judge whether they have the right to renew books, and output the processing results to a temporary table.

Create process user_renew_book @xxxparm int AS

Create table ##temp (statement varchar(50))

Declare @ username varchar(50)

SET @username= (select log b_cons_username from user logs, where ID=@xxxparm).

If the @ user name is empty

begin

Insert into # # temporary value ("ID does not exist")

return

end

Declare @timelimit int

SET @ time limit =(select log b _ time limit from user _ logBook where ID = @ xxxparm)

Declare @renewday int

SET @ renew day =(select cons _ maxday from user _ consumer where cons _ username = @ username)

Declare @ maxrenewaint

SET @ max renew =(select cons _ max renew from user _ consumer where cons _ username = @ username)

IF(@ renew day * @ max renew)& gt; = @ Time limit

begin

Update user _ logbook set logb _ timelimit = logb _ timelimit+@ renewday where ID=@xxxparm.

-updateuser _ consumerset cons _ maxupdates = cons _ maxupdates-1where cons_username=@username.

Insert # # temporary value ("Renewal succeeded")

return

end

other

begin

Insert # # temporary value ("You are not allowed to renew books")

return

end

go to

Due reminder table view

Use DATEDIFF, DATEADD, CAST, GETDATE and other functions to calculate the expiration record from the book borrowing record table, and then find out the corresponding reader information according to this record, and return it by email on the webpage.

Create view dbo.deadline

be like

SELECT TOP 100% dbo . user _ logbook . log b _ cons _ username,

dbo.user_logBook.logb_outdate,DATEADD(【day】,dbo . user _ logbook . logb _ time limit,

CAST(dbo . user _ logbook . logb _ outdate AS datetime))AS deadline _ date,GETDATE()

AS now_date,dbo.user_consumer.cons_name,dbo.user_consumer.cons_kind,

dbo.user_consumer.cons_rank,dbo.user_consumer.cons_email

dbo . user _ consumer . cons _ max renew,dbo.user_consumer.cons_maxbook,

dbo . user _ logbook . logb _ book _ ISBN,dbo.user_book.book_name,

dbo.user_book.book_kind,dbo.user_book.book_storage,dbo.user_book.book_rank,

dbo . user _ logbook . logb _ time limit

FROM dbo.user_logBook internal connection

dbo.user_consumer ON

Dbo. user _ logbook. log b _ cons _ username = dbo. user _ consumer. cons _ username INNER

join

dbo.user_book ON

dbo . user _ logbook . logb _ book _ ISBN = dbo . user _ book . book _ ISBN

In which (DATEDIFF(【day], DATEADD(【day], dbo.user _ logbook.logb _ time limit,

CAST(dbo . user _ logbook . logb _ outdate AS datetime)),GETDATE())& gt; = 0) and

(dbo.user_logBook.logb_backdate is empty)

Orders are based on dbo.user _ logbook.logb _ cons _ usernamedesc.

3.2 Data Link Layer Design

Entity bean

User manual entity Bean design

User Manual Remote Home Interface

Method description

FindAllBook to get all the book information.

FindByISBN obtains book information by book number.

FindSearcher uses keyword fuzziness to find book information.

selectUserByBookISBN

(userbook remote) uses the select method to realize multi-table association search.

Code for fuzzy search:

Select the object (p) from the user manual as p where p.bookName is similar to concat (concat ('%',? 1),'%') or do the authors of p. book like it? 1 or p. book or something? 1 or p.book. Do you like it? 1 or p.bookAbstract like? 1 or p.books bn like concat (concat'%',? 1),'%') or p.bookRemark like? 1

User consumer entity Bean design

User-consumer remote home interface

Method description

Find all user information.

FindByUsername looks up user information by user name.

FindSearcher uses keyword ambiguity to find user information.

Select bookby user name.

(userconsumer remote) uses the select method to realize multi-table association search.

Code for fuzzy search:

Select object (p) from UserConsumer as p where p. consumer name is like concat (concat ('%',? 1),'%') or p.consSerial like? 1 or p.cons name like concat (concat ('%',? 1),'%') or p.consRemark like? 1 or p.consEmail or something? 1

Design of user log entity Bean

User Log Remote Home Interface

Method description

FindallbybookISBN searches all the borrowing records of this book.

Find the current borrowing record of this book.

Findallbyusername to find all the borrowing records of this user.

Find the user's current borrowing record.

Findbacklog gets the borrowing records of all returned books.

Findoutlog gets the borrowing records of all the books that have not been returned.

FindbyID finds the book borrowing record by recording the serial number.

Find the book borrowing record of a certain date.

(Fuzzy matching, such as submitting "May 2004" to get the final record time-borrowing or returning all borrowing records in May 2004)

Findallog got all the book borrowing records.

FindLogByDay obtains a set of codes for the final recording time through fuzzy matching:

Select the object (p) from the user log as p where (p.logbBackdate is empty and p.logbOutdate is concat (concat (%',? 1),'%') or (p.logbBackdate is not empty and p.logbBackdate likes concat (concat ('%',? 1),'%') )

3.3 Data Logic Layer Design

Session bean

Design of book conversation Bean

Shudou

Realize the functions of adding, deleting, changing and searching books, fuzzy searching, searching readers through books and so on.

Method internally implements all logical processing and conversion, and returns to the remote interface value object or value object vector.

User session Bean design

User bean

Users (readers) can add, delete, change, search and search books through readers and other functions.

Method internally implements all logical processing and conversion, and returns to the remote interface value object or value object vector.

Log session Bean design

carob

It mainly realizes various operations on the log (book borrowing record), and provides various methods to obtain the log (by reader, by book, by date, by borrowing and returning status, etc.). ). All logical processing and transformation are realized inside the method and returned to the remote interface value object or value object vector. In addition, there are the following methods:

Method function

Public Boolean Userborrowbook (String User Name, String Book ISBN) encapsulates all the logical operations of readers to borrow books through one transaction. You can't return a false value when borrowing a book successfully, so you call enCode bean to transcode Chinese.

The public Boolean user return book(String Logbid) encapsulates all the logical operations of returning books by a transaction, that is, it realizes the function of writing off the borrowing records, and calls enCode bean to transcode Chinese.

The public vector show log between days (string day begin, String Day End) returns all the logs between two dates, mainly by using the Calendar class.

3.4 Network Application Layer Design

This layer is designed according to the principles of encapsulation, data fuzziness and reusability of object-oriented thought.

Based on the principle of error handling (System.out.println) of printing system operation errors in the system, user input and misoperation errors will lead to friendly error handling pages and give friendly prompts.

Every call to the session bean is written into the system running log file, and the default path is c: \ \ booksmanagerlog.dat.

Check value bean

Encapsulates multiple static methods.

It can be used to detect whether a certain value already exists in a certain field in the table (it can be used to detect duplicate users and duplicate books), and to detect the legality of user name, password, age, email, number, date, etc.

Coded bean

Packaging, coding and transcoding:

Html display transcoding, for example, conversion

Chinese transcoding that can be overloaded.

Encryption and decryption coding of passwords.

JDBCBean bean

Encapsulates all database operations. Including SQL execution methods with result set return and SQL execution methods without result set return.

Grade bean

Encapsulating page access with four permissions (general reader, user administrator, librarian and system administrator) is equivalent to page locking function.

Install bean

Public static string title = "superlibrary"; //System name

Public static string DBS = "Booksmanagerds"; //JNDI name of the database

Common static string errorpage = "dealerror.jsp? theError =“; //Friendly error handling page, with the get method to pass the error reason.

Public static string homepage = "default.jsp"; //Default Home Page

//authority-.

Public static string reader = "reader"; //readers

Public static string useradmin = "useradmin"; //User Administrator

Public static string bookadmin = "bookadmin"; //Librarian

Public static string superadmin = "superadmin"; //System Administrator

//Grade-.

Public static String undergraduate = "undergraduate"; //undergraduates

public static int undergraduate renew = 1; //The number of times undergraduates can renew their loans.

public static int undergraduate maxday = 30; //The number of days that undergraduates can borrow at a time.

Public static string graduate = "graduate"; //graduate students

public static int graduate new = 2; //The number of times graduate students can renew their loans.

public static int graduate max day = 45; //The number of days that graduate students can borrow at a time.

Public static String Teacher= "teacher"; //teacher

public static int teacher new = 3; //The number of times the teacher can renew it.

public static int teacher max day = 60; //The number of days a teacher can borrow at a time.

// -

public static int rsPerPage = 5; //Displays the number of records per page.

public static int min books = 4; //The system default minimum borrowing quantity.

SplitPage bean

The logical realization of data record paging and page display (the simplest, which can be beautified by external style sheets) is encapsulated in a bean. When reusing, you only need to pass some parameters of a recordset, which is reusable. Generally, it is called as a session-level java bean in a page, and the user's access status to the page is saved in the session, and the page number corresponding to the user's access to the page is always remembered before the session ends.

User login bean

The logical realization of user login and page display (the simplest, which can be beautified by style sheets) is encapsulated in a bean, including the handling of various login situations of users, which can be reused.

Search for book beans

Using JDBC to realize the functions of fuzzy search and accurate search of books according to specific categories.

SearchDeadline bean

Using JDBC call view to realize the function of returning expired books.

Verify servlet

Dynamically generate a picture with a random verification code, write the verification code into the session while generating the picture, and compare it with the user's login input. It can effectively prevent robots from logging in.

GetDelete servlet servlet

Handle the logout operation of books, users and logs, and jump to the corresponding page according to the return value.

GetBookSubmit servlet

Handle the storage of books and the modification of book information, and jump to the corresponding page according to the return value.

GetUserSubmit servlet

Handle user registration and user information modification, and jump to the corresponding page according to the return value.

GetRenewBook servlet

Handle the user's request to renew the book (JDBC calls the stored procedure), read the status value from the temporary table of the system, and jump to the corresponding page according to the status value.

GetBorrowBook servlet

Handle the user's request for borrowing books, and guide the errors such as the user's borrowing quota is full and the inventory is zero to the friendly error page. If the book is borrowed successfully, jump to the book information page and give the corresponding prompt.

GetReturnBook servlet

Handle the user's book return request. If the book is returned successfully, jump to the user's book borrowing record page and give the corresponding prompt.

4 program architecture

4. 1 project organization structure

Description: As the external functions of the system, book search and user login directly call the database through JDBC, in which the user login module is encapsulated in a java bean and can be reused. In addition, users renew books through stored procedures, thus bypassing entity bean that use CMP technology to manage transactions.

The organizational structure of other projects in this system is strictly in accordance with the following figure:

Plan organization chart

4.2 Division of functions and authorities

Website page map

The rights name system defines the rights of a role to access a page.

Ordinary readers read their own information (return books, renew books);

Modify your own information;

Look up books (borrow books); User modification

User view

book list

Librarian BookAdmin has the authority of ordinary readers;

Add, delete and check books;

Repayment due; User modification

User view

book list

bookkeeper

Book revision

deadline

User administrator UserAdmin has the rights of ordinary readers;

Add, delete and query users; User modification

User view

book list

User register

User modification

User list

SuperAdmin, the system administrator, has the rights of librarian and user administrator;

View the system log;

Delete the system log;

System settings; All pages including setupSYS.jsp (system settings, using application-level java bean to control the whole application).

4.3 Network Program/Page Design

use

Use onfocus = this. select()onmouseover = this。 The focus () code makes the text box automatically absorb and get the focus, which is convenient for users to input.

Using WMODE =“transparent "parameter can make the background of flash transparent and better integrate into the web page.

On each page, use the code:

& ltIFRAME frame border = 0 height = 88 margin height = 0 margin width = 0 scrolling = no src =“../iframe/top . htm“width = 755 border color =“# 000000“& gt; & lt/IFRAME & gt;

& ltIFRAME frame border = 0 height = 68 margin height = 0 margin width = 0 scrolling = no src =“../iframe/below . htm“width = 755 border color =“# 000000“& gt; & lt/IFRAME & gt;

The upper and lower navigation bars are embedded, which makes the website navigation clear and convenient for users to browse.

Add code to the header:

& ltmeta HTTP-EQUIV =“pragma“CONTENT =“no-cache“& gt。

& ltmeta HTTP-EQUIV =“expires“CONTENT =“0“& gt;

The client does not cache the webpage, which ensures that the client can get the latest version from the server every time it browses the webpage, thus displaying the webpage correctly.

Provide intelligent search (get as many matches as possible) and accurate search (get as accurate matches as possible) books, and adopt fuzzy search method in server-side programming.

Use javascript on the client to check the form submission for the first time and then submit it to the server for the second time. The check code includes: whether the user name is duplicate, whether the age is an appropriate number, whether the two passwords are consistent, whether the email is legal, whether the password is too short, whether the user name is too short, whether the user name password is empty, and so on.

Using the method of randomly generating JPG picture verification code to prevent robots from logging in.

Use session-level java bean to achieve paging in the page, save the user's access status to the page in the session, and always remember the page number corresponding to the user's access to the page before the end of the session.

Use application-level java bean to achieve secure system settings in the page. When the server is started, the system running parameters can be set at the application level. As long as the server is not shut down, this setting is always valid and applies to all users. If careless settings cause system errors or you want to restore the system default settings, you just need to restart the server.

In ejbClient, the call package of session bean, a system running log is created and written into C:\\booksManagerLog.dat of the web server through the writeF class in the package, which can be used for query.

4.4 Functions realized by this system

Determine the basic information of the book, including the title, author, publication date, current borrowing status and other attributes.

The users of the system include readers, librarians, user administrators and system administrators.

Readers can query books; Librarians can complete book management and borrowing management; The reader administrator can complete the function of reader management; System administrators can use all the functions of the system.

Book management: new book registration, book inquiry and book cancellation;

Borrowing management: borrowing and returning books, and inquiring overdue readers.

Reader management: increase readers, delete readers, query readers and manage reader categories (set the number of books that can be borrowed, the number of days that can be borrowed and the number of times that can be renewed for graduate students, undergraduates and teachers. )

System management: used by system administrators, including user rights management (adding users, deleting users, modifying passwords, etc. ), system borrowing log, system running log, system settings and other functions.

The page is entered with a verification code, and password access is encrypted.

Reservation expiration reminder

Reflect the hierarchical design idea and use MVC architecture.

A number of beans are realized, and the corresponding relationship between beans is realized.

EJB QL, transaction control and so on are all used.

Use JSP-& gt;; Session bean->; entity bean-& gt; Database schema

The database uses some advanced technologies such as triggers and stored procedures.