Download as pdf or txt
Download as pdf or txt
You are on page 1of 91

Online Library Management System 1

Online Library Management


System

By
Bikramjit Banerjee

Under the Guidance of

Ms. Pallabi Chakraborty

Thesis Submitted for the Partial Fulfillment of the Degree of


BACHELOR OF TECHNOLOGY

IN

Computer Science

DEPARTMENT OF COMPUTER SCIENCE

CAMELLIA SCHOOL OF ENGINEERING & TECHNOLOGY COLLEGE

West Bengal University of Technology

Kolkata, West Bengal, India.


Online Library Management System 2

Certificate
This is to certify that this thesis entitled‖Online Library Management System” is a bona-fide
record of work done by:

Bikramjit Banerjee

ROLL NO-********* SESSION:-******

REGISTRATION NO-************ OF *********


Under my guidance and supervision, submitted in partial fulfillment of the requirements for the award of
Bachelor of Technology (Computer Science) by the West Bengal University of Technology.

Ms. Pallabi Chakraborty

Assistant Professor

Computer Science of CSeT, Kolkata

MR. ARNAB BISWAS

Head of Department, Computer Science

Of CSeT, Kolkata

PROF. A.S.CHODHURY

DIRECTOR of CSeT, Kolkata

Signature of External Examiner


Online Library Management System 3

ACKNOWLEDGEMENT

I take this opportunity to convey my sincere gratitude to My Project Guide Ms.


Pallabi Chakraborty of CSeT,Kolkata, for not only suggesting me the Project but
also for her constant guidance, inspiration, motivation, patience and valuable
suggestions & time , given to me throughout the project Development and
Documentation.

At the same time I am highly obliged to the other members of my Project Team, for
their sincere assistance, co-operation and encouragement, throughout the Project
Work. I thank them all, as without them it would not have been possible for me to
complete this project successfully.

Last but not the least, I would like to thank the entire college along with our
respected Principal sir, our HOD, and all other Faculty Members of my College, as
they have all contributed some way or the other, to help me successfully execute
this herculean task.

Thanking You All.

DATE: Bikramjit Banerjee


Online Library Management System 4

Table of Contents
Introduction
Purpose 5
Scope 6
Definitions, Accronims, Abbreviations 6
Reference 7
Technologies 7
Cost Estimation 8
Software Development Life Cycle 9
Feasibility Study 10
Overview 11

Overall Description
Product Perspective 11
Product Functions 12
User Charecteristics 13
Constraints 13
Assumptions & Dependencies 13

Specific Requirements
Functional Requirements 14
Non- Functional Requirements 15
Other Non- Functional Requirements 15

Diagrams
Data Flow Diagram (DFD) 16
Entity Relationship Diagram (ERD) 17
Use Case Diagram (UCD) 18

Project Detail
Data Dictionary 19
Project Snapshots 23
Project Coding 32
Java Documentation(JAVA DOC) 13

Code Efficiency 84
Optimization Of Code 84
Validation Checks 84
Testing 85
Security Measures Taken 88
Future Scope 89
Conclusion 90

Bibliography 91
Online Library Management System 5

Software Requirement Specifications

INTRODUCTION

In this 21th century borrowing and returning books or viewing the available books at the Library
of the local University is currently done manually where in the student has to go to the Library
and check the available books at the Library. Students check the list of books available and
borrow the books if the book is available to be borrowed otherwise it is of waste of time for the
students to come to the library to check for the books if the student doesn’t get the book. In the
case if book is available the librarian checks the member id and allows the member to check out
the book and the librarian then updates the member database and also the books database
manually which requires more time and more than one Staff.

Now to get rid of this problem of time wastage here we suggest the idea of Online
Library Management System that would be used by members who may be students or Faculty
members of that University to check the availability of the books and borrow/return or reserve the
books etc. and databases is updated within less time by Librarian i.e. Administrator.

Purpose

The purpose of this document is to analyze and elaborate on the high-level needs and
features of the Online Library Management System. It focuses on the capabilities and facilities
provided by a Library. This system can be used to search for books/magazines, reserve books,
find out who is having a particular book, put in requests to buy a new book etc. This is one
integrated system that contains both the user component and the librarian component and both the
end users and librarian have their own different rights to access the database of system.

The purpose of Software Requirements Specification (SRS) document is to describe the


external behavior of the Online Library Management System. Requirements Specification defines
and describes the operations, interfaces, performance, and quality assurance requirements of the
Online Library System. The document also describes the non-functional requirements such as the
user interfaces. It also describes the design constraints that are to be considered when the system
is to be designed, and other factors necessary to provide a complete and comprehensive
description of the requirements for the software. The Software Requirements Specification (SRS)
captures the complete software requirements for the system, or a portion of the system.
Requirements described in this document are derived from the Vision Document prepared for the
Online Library System.
Online Library Management System 6

Scope

The Software Requirements Specification captures all the requirements in a single


document. The Online Library Management System that is to be developed provides the members
of the Library and employees of the library with books information, online borrowing and
returning of books and many other facilities. The Online Library System is supposed to have the
following features.

 The product provides the members with online reservation of books capabilities and the
Online Library System is up and running all day.
 The system provides logon facility to the users.
 The system provides the members with the option to check their account and/or change their
options like password of the account whenever all through the day i.e by this system the user
needed get 24*7 supports.
 The system lets the library staff to check which all members have reserved the books and
whether they can borrow any more books or not.
 The system allows the Librarian to create the books catalogue, add/delete books and maintain
the books catalogue.
 The system updates the billing system as and when the member borrows or returns a book.
 The book catalogue is automated which changes according to user and Administrator action.
 Members can borrow multiple books at the same time.
 There will be mainly two Entity using this application :-
1) Librarian who will be acting as the administrator.
2) Book, authors, publishers and faculty members of the Campus who will be
accessing the Library online.

Definitions, Acronyms and Abbreviations

HTML: Hypertext Markup Language is a markup language that is used to design static web
pages.

J2EE: Java 2 Enterprise Edition is a programming platform— part of the Java Platform—for
developing and running distributed multitier architecture Java applications, based largely on modular
software components running on an application server.

Microsoft Access : MS ACCESS Database is the database management system that delivers a
flexible and cost-effective database platform to build robust on demand business applications
Online Library Management System 7

Apache Tomcat: Apache Tomcat application server is an application server that runs business
applications and supports the J2EE and web services standards.

HTTP: Hypertext Transfer Protocol is a transaction oriented client/server protocol between web
browser & a Web Server.

HTTPS: Secure Hypertext Transfer Protocol is a HTTP over SSL (secure socket layer).

References

 SRS format from IEEE standard SRS format

Technologies

Software Platform:

Server side developments will be with JAVA language and J2EE architecture. Apache
Tomcat server 6.0.20 and above will be used as application server. We will use JDK1.6.0_11.
Client side scripting specially for validation checking is done with JAVASCRIPT.

MICROSOFT ACCESS is used as database server.

Development Environment:

NetBeans IDE 6.8 is used for developing the entire application. Spring Framework &
jQuery has been used.

O/S:

Since we are choosing JAVA Technology thus the server could be implemented on any
standard O/S that includes JDK1.6.0_11

Client:

Any standard browser could serve as client. This project is supported by Internet Explorer
6.0 onwards and Mozilla Firefox version 3 and 3.5 beta 3 onwards.
Online Library Management System 8

COST ESTIMATION OF THE PROJECT


Basic COCOMO is a static, single-valued model that computes software development effort (and cost)
as a function of program size expressed in estimated lines of code. COCOMO applies to three classes of
software projects:

 Organic projects - are relatively small, simple software projects in which small teams with good
application experience work to a set of less than rigid requirements.
 Semi-detached projects - are intermediate (in size and complexity) software projects in which
teams with mixed experience levels must meet a mix of rigid and less than rigid requirements.
 Embedded projects - are software projects that must be developed within a set of tight hardware,
software, and operational constraints.

The basic COCOMO equations take the form

Effort = ab (KLOC) bb
D= cb (E)db
P=E/D
Where,
Effort is the total effort required to develop the software product expressed in person-months,
D is the development time in chronological months,
KLOC is the estimated number of delivered lines of code for the project (expressed in thousands)and it
stands for Kilo Lines of Code,
P is the number of people required.

The coefficients ab, bb, cb and db are given in the following table.

Software project ab bb cb db

Organic 2.4 1.05 2.5 0.38


Semi-detached 3.0 1.12 2.5 0.35
Embedded 3.6 1.20 2.5 0.32

Our Project is an Semi-detached Project.

KLOC in our project is 12

So, Effort = 3.0* ( 12 )1.12 PM = 48.50 PM

Development Time D =2.5*( 48.50 )0.35 Months. = 10.9 Months

From the effort estimation, the project cost is obtained by multiplying the required effort by the
manpower cost per month. In addition to manpower cost, a project would incur costs due to hardware and
software required for the project.
Online Library Management System 9

SOFTWARE DEVELOPMENT LIFE CYCLE


(ITERATIVE WATERFALL MODEL)

We have followed the Iterative waterfall model for our project.

Incremental development is a scheduling and staging strategy, in which the various parts of the
system are developed at different times or rates, and integrated as they are completed. Key steps
in the process are to start with a simple implementation of a subset of the software requirements
and iteratively enhance the evolving sequence of versions until the full system is implemented.
At each iteration, design modifications are made and new functional capabilities are added.

(Picture No 0)
Online Library Management System 10

FEASIBILITY STUDY
The main aim of the feasibility study is to determine whether it would be financially and
technically feasible to develop the product. This study involves the analysis of problem and
collection of all relevant information relating to the product (e.g. different data items as input to
the system, required processing on the data, output data that would be produced by the system
and various constraints on the behaviour of the system.). The collected data are analyzed to
arrive at the following:

 An abstract problem definition or a rough definition of the problem considering only the
important requirements.
 Formulation of the different solution strategies.
 Analysis of alternative solution strategies to compare their benefits and shortcomings.

FEASIBILITY STUDY FOR ONLINE LIBRARY MANAGEMENT SYSTEM: -

An Online Library Management System also has some definite input to the system, some predetermined
processing carried out on them and required output from the system. The input to the system can be of the
following types:

 Administrators, Members must give appropriate user-id and password for log in.
 Members can select from any available book at any point of time.
 Members can select an book from the available book options.
 Members can view any of the trasaction made by him/her in the member inbox.

The output from the system can be:


 The transactions for every member are recorded for each and every operation.
 The feasible transaction is done on request.

Some constraints on the system are:


 Each book is issued for a validity period of time, before or after that time-frame no member could
be able to borrow the books, that is, that particular book will not be available for the members
once it is unavaliable..
 No excess book can be issued greater than the maximum limit for a particular user.

These estimates are used as the basis for comparing the different solutions. Once the best solution is
identified, all the later phases of development are carried out as per this solution. Thus, during the
feasibility study, most of the high-level architectural design decisions are made. Therefore, feasibility
study is considered to be a very important stage.
Online Library Management System 11

Overview

SRS will include two Major sections:

Overall Description:

This section of the SRS will provide the general factors that affect the product and its requirements. It
provides the background for those requirements. The items such as product perspective, product function,
user characteristics, constraints, assumptions and dependencies and requirements subsets are described in
this section.

Requirement Specification:

This section of SRS contains all the software requirements mentioned in section 2 in detail
sufficient enough to enable designers to design the system to satisfy the requirements and testers to test if
the system satisfies those requirements.

Overall Description

Product perspective

The Online Library System is a complete package to be used by Libraries to improve the
efficiency of Librarians, Library employees and Users. The Online Library System to be
developed benefits greatly the members and the Librarian of Campus. The system provides
books catalog and information to members and helps them decide on the books to borrow from
the library. The Librarian can keep the books catalog updated all the time so that the members
(students, faculty, author and publisher) get the updated information all the time.

The complete overview of the system is as shown in the overview diagram below:
Online Library Management System 12

HTML Clients HTTP/HTTPS

(Members)

WAS MS
ACESS
ApacheTomcat
DB

Client Software
TCP/IP
(System User)

 The web pages (XHTML/JSP) are present to provide the user interface on customer client
side. Communication between Members and server is provided through HTTP/HTTPS
protocols.
 The Client Software is to provide the user interface on system user client side and for this
TCP/IP protocols are used.
 On the server side web server is for hosting jsp and other application pages and database
server is for storing the information of books and members.

Product Functions
The Online Library System provides online real time information about the books available in the
Library and the user information. The Product functions are more or less the same as described in the
product perspective. The functions of the system include the system providing different type of services
based on the type of users [Member/Librarian].

 The member should be provided with the updated information about the books
catalogue.
 Provisions for the members to borrow the books which they want, if all the other
required rules hold good.
 The member is given a provision to check his account information and change the
account information any time in the given valid period.
 The members are provided with the books available roster and allowed to choose the
books, which they want to use in the coming up days.
 The librarian can get the information about the members who have borrowed or
returned the books.
 The librarian is provided with interfaces to add/delete the books available in the book
catalogue.
Online Library Management System 13

 The members when complete the book borrowing or returning process, the due to be
paid by the member must be calculated and the information about the member and
the due amount is sent to the university billing system.
 The system uses the University information security requirements to provide the
login facility to the users.

User Charecteristics
The users of the system are members, librarian of the university and the administrators who
maintain the system. The members and the librarian are assumed to have basic knowledge of the
computers and Internet browsing. The administrators of the system to have more knowledge of the
internals of the system and is able to rectify the small problems that may arise due to disk crashes, power
failures and other catastrophes to maintain the system. The proper user interface, users’ manual, online
help and the guide to install and maintain the system must be sufficient to educate the users on how to use
the system without any problems.

Constraints
 The information of all the users must be stored in a database that is accessible by the
Online Library System.
 The Online Library System is connected to the university computer and is running all 24
hours all day.
 The users access the Online Library System from any computer that has Internet
browsing capabilities and an Internet connection.
 The users must have their correct usernames and passwords to enter into the Online
Library System.
Hardware Constraints
The system requires a database in order to store persistent data. The database should have backup
capabilities.
Software Constraints
The development of the system will be constrained by the availability of required
softwares such as web servers, database and development tools.
Design Constraints
The system must be designed to allow web usability. That is, the system must be designed in such
a way that will be easy to use and visible on most of the browsers.

Assumptions & Dependencies


 There is single library in Campus.
 Each book of the library is identified by unique ID..
 The users know the English language, as the user interface will be provided in English.
 The application can access the university student database.
Online Library Management System 14

Specific Requirements
Functional Requirements
This section gives the list of Functional requirements which are applicable to the Library
Management System.

Interface Requirements
This section describes how the software interfaces with other software products or users for input
or output.

User Interfaces
Describes how this product interfaces with the user.

GUI
Describes the graphical user interface if present. This section should include a set of screen
dumps or mock-ups to illustrate user interface features.

Description
The user interface must be customizable by the administrator

Criticality
This issue is essential to the overall system. All the modules provided with the software must fit
into this graphical user interface and accomplish to the standard defined.

Technical issues
In order to satisfy this requirement the design should be simple and all the different interfaces
should follow a standard template. There will be the possibility of changing colors and images, plus
switching between interfaces with the minimum impact for the users.

Risks
To reduce the circumstances under which this requirement might not able to be satisfied, all the
designers must have been developed web sites previously and they must be aware of html restriction and
cross browsers implementations before starting the designing. In order to reduce the probability of this
occurrence the entire design team will be trained in basic html development and macromedia fireworks,
this tool will be used instead of Photoshop.

Dependencies with other requirements All user interfaces should be able to interact with the
user management module and a part of the interface must be dedicated to the login/logout module
Online Library Management System 15

Non Functional Requirements


User Interfaces

Hardware Interfaces
Server Side: Client side:
Operating System: Windows 9x/xp ,Windows Operating System: Windows 9x or above, MAC
ME or UNIX.
Processor: Pentium 3.0 GHz or higher Processor: Pentium III or 2.0 GHz or higher.
RAM: 256 Mb or more RAM: 256 Mb or more
Hard Drive: 10 GB or more

Software Interfaces
Database: Microsoft Access 2007

Application: JSP(Java Server Pages)

Web Server: ApacheTomcat (Apache Tomat is a powerful Web server that provides a highly reliable,
manageable, and scalable Web application infrastructure)

Other Non-functional Requirement


Safety Requirements
The database may get crashed at any certain time due to virus or operating system failure.
Therefore, it is required to take the database backup.

Security Requirements
We are going to develop a secured database for the university .There are different categories of
users namely teaching staff, administrator, library staff ,students etc., Depending upon the category of
user the access rights are decided. It means if the user is an administrator then he can be able to modify
the data, delete, append etc.,All other users other than library staff only have the rights to retrieve the
information about database.

Software Quality Attributes


The Quality of the database is maintained in such a way so that it can be very user friendly to all
the users of the database.
Online Library Management System 16

DIAGRAMs:
DATA FLOW DIAGRAM(DFD)
Online Library Management System 17

Entity Relationship Diagram(erd)

It is clear that the physical objects from the previous section the
member, books, library correspond to entities in the Entity-relationship
model, and the operations to be done on those entities – holds,
checkouts, and so on – correspond to relationships. However, a good
design will minimize redundancy and attempt to store all the required
information in as small a space as possible.
Online Library Management System 18

USE CASE Diagram (UCd)

Here

 <<i>> stands for <<include>>


 <<e>> stands for <<extend>>
Online Library Management System 19

PROJECT DETAILS:
DATA DICTIONARY
BookMaster

BookMaster Table for the Library System


Description: This table is used for keeping the book record in the database.
BookId Used to store the unique bookid for each book of the system

Title This column Store the title of the book for the system

Author1 Stores author name 1 for each book

Author2 Stores author name 2 for each book

Author3 Stores author name 3 for each book

Publisher Stores the publisher information for each book

Subject This is used for the subject of the book

Price Price of the book is stored here

DOP Date of purchase of the book

IsAvaliable This keeps the record of the book is available to user or not

ISBN Keeps the book isbn number


Online Library Management System 20

Member

Member Table For the Library System


Description: This table is used for keeping the member record in the database.
CardNo This is the unique CardNo assigned to Every User

FirstName Stores the First Name of the user

LastName Stores the last name of the user

Road The address of the user is stored here

City City of the user’s residence is stored in this column

Pin Stores the pin code of the user

Mobile Contact information of the user

Email Email id of the user is kept here

Sex Sex of the user is stored

Password The access password of the user is kept in the column in encrypted format to
maintain security
BCount The maximum book count of a user is stored

DOJ Date of joining of the user to the library is stored

DOB Date of birth of the user is stored here

Block It stores that the user is blocked or not

WhyBlocked If a user is blocked it stores the comment of it


Online Library Management System 21

Transaction

Transaction Table For The Library System


Description: This table is used for keeping the member transaction record in the database.

TransactionId This is used to keep the unique transaction id for each transaction held in
the library System

CardNo The card no of the user with whom the transaction is held

BookId The bookid of which the transaction is done

IssueDate Date of issue of the book to the user

ReturnDate Date of return of the book to the library

FineAmount Calculated fine amount for the defaulter member after the return period

UserId User id of the administrator who was active during the transacion
Online Library Management System 22

UserMaster

UserMaster Table for the Library System


Description: This table is used for keeping the administrator account record in the database.
Userid This column stores the unique administrator userid for the system

Password This column stores the encrypted user password for the respective
users

Username This column used to store the username of the administrator

type This column shows that if the user of the system is active or not
Online Library Management System 23

--PROJECT SNAP SHOTS—


Welcome Screen:

Admin User Home:


Online Library Management System 24

Admin Mode User Creation:

Admin Mode New User ID & Password Generation:


Online Library Management System 25

Admin Mode User Search:

Admin Mode User Search Result Found:


Online Library Management System 26

Admin Mode User Update:

Admin Mode User Block:


Online Library Management System 27

Admin Mode Insert Book:

Admin Mode Search Book:


Online Library Management System 28

Admin Mode Update Book:

Admin Mode Book Transaction (ISSUE):


Online Library Management System 29

Admin Mode Book Transaction (RETURN):

Admin Mode Reports (Defaulter Member List):


Online Library Management System 30

User Mode Password Change:

User Mode Profile Update:


Online Library Management System 31

User Mode Book Search:

User Mode Member Inbox (Transaction Record):


Online Library Management System 32

PROJECT CODING:
Context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/OnlineLibrary">
<Resource auth="Container" driverClassName="sun.jdbc.odbc.JdbcOdbcDriver" maxActive="150"
maxIdle="10" maxWait="-1" name="jdbc/Library_Acc" password="" type="javax.sql.DataSource"
url="jdbc:odbc:lib" username=""/>
</Context>

BlockMemberServlet.java

package onlinelibrary.allservlets;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import onlinelibrary.beans.Member;
import onlinelibrary.util.DBConnection;

public class BlockMemberServlet extends HttpServlet {


/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
Online Library Management System 33

* @param request servlet request


* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
Connection conn =null;
Vector<Member> members=(Vector<Member>) request.getSession().getAttribute("members");
try {
conn = DBConnection.getConnection();

String strRecno =request.getParameter("recno");


Integer recno =null;
if(strRecno.equals(""))
recno = members.size();
else
recno = Integer.parseInt(strRecno);

request.setAttribute("recno", recno);
Member amember = members.get(recno-1);
String reason = request.getParameter("why");
System.out.println(this.getClass().getName() + " : RecNo: " + recno + " CardNo: " +
amember.getCardno());
if (!amember.isBlocked()){
amember.setWhyblocked(reason);
amember.blockMember(conn);
amember.setBlocked(true);
request.setAttribute("updatemsg", "Member [ Card No: " + amember.getCardno() +" ] has been
blocked ");
Online Library Management System 34

request.setAttribute("members", members);
//request.getSession().removeAttribute("members");

this.getServletContext().getRequestDispatcher("/office/searchmemberresult.jsp").forward(request,
response);
return;
}
else{
request.setAttribute("updatemsg", "Member [ Card No: " + amember.getCardno() +" ] already
blocked...");
request.setAttribute("members", members);
//request.getSession().removeAttribute("members");

this.getServletContext().getRequestDispatcher("/office/searchmemberresult.jsp").forward(request,
response);
return;
}
}
catch(Exception ex){
request.setAttribute("updatemsg", "Unable block member, for " + ex.toString() + " view log for
details");
request.setAttribute("members", members);
this.getServletContext().getRequestDispatcher("/office/searchmemberresult.jsp").forward(request,
response);
Logger.getLogger(MemberOperationControllerServlet.class.getName()).log(Level.SEVERE, null,
ex);
}
finally {
out.close();
try {
conn.close();
} catch (SQLException ex) {
Logger.getLogger(BlockMemberServlet.class.getName()).log(Level.SEVERE, null, ex);
}
}
Online Library Management System 35

}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to
edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
} /**
* Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
} /**
* Returns a short description of the servlet.
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
Online Library Management System 36

return "Short description";


}// </editor-fold>
}

ChangePasswordServlet.java
package onlinelibrary.allservlets;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
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 onlinelibrary.beans.Member;
import onlinelibrary.beans.UserMaster;
import onlinelibrary.util.DBConnection;
import onlinelibrary.util.FTPasswordService;

public class ChangePasswordServlet extends HttpServlet {


/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
Online Library Management System 37

*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
Connection conn = null;
HttpSession session = request.getSession(true);
Integer usertype = (Integer)session.getAttribute("usertype");
String oldpassword_actual="";
String oldpassword_given ="";
Member loggedmember = null;
UserMaster loggeduser = null;
if (usertype==1){
loggedmember =(Member)session.getAttribute("user");
oldpassword_actual = loggedmember.getPassword();
oldpassword_given = request.getParameter("oldpassword");
oldpassword_given = new FTPasswordService().encrypt(oldpassword_given);
}
else if(usertype==2){
loggeduser =(UserMaster)session.getAttribute("user");
oldpassword_actual = loggeduser.getPassword();
oldpassword_given = request.getParameter("oldpassword");
oldpassword_given = new FTPasswordService().encrypt(oldpassword_given);
}
if (!oldpassword_given.equals(oldpassword_actual)){
request.setAttribute("genmsg", "Invalid Old Password");
this.getServletContext().getRequestDispatcher("/office/changepassword.jsp").forward(request,
response);
return;
}
try {
Online Library Management System 38

conn = DBConnection.getConnection();
String strSQL = "";
if (usertype==1)
strSQL = "update member set Password=? where CardNo=?";
else if(usertype==2)
strSQL = "update usermaster set Password=? where UserId=?";

System.out.println("Usertype: " + usertype+" sql: " + strSQL);


PreparedStatement pstmt1 = conn.prepareStatement(strSQL,
ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
String newpassword = request.getParameter("newpassword1");
newpassword = new FTPasswordService().encrypt(newpassword);
pstmt1.setString(1, newpassword);
if (usertype==1)
pstmt1.setString(2, loggedmember.getCardno());
else if (usertype==2)
pstmt1.setString(2,loggeduser.getUserid());
pstmt1.executeUpdate();
request.setAttribute("genmsg", "Password changed successfully...");
this.getServletContext().getRequestDispatcher("/office/changepassword.jsp").forward(request,
response);
}
catch(Exception e){
request.setAttribute("genmsg", "Password changing failed...View log for details");
Logger.getLogger(ChangePasswordServlet.class.getName()).log(Level.SEVERE, null, e);
}
finally {
out.close();
try {
conn.close();
} catch (SQLException ex) {
Logger.getLogger(ChangePasswordServlet.class.getName()).log(Level.SEVERE, null, ex);
Online Library Management System 39

}
}
}

// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to


edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
Online Library Management System 40

* Returns a short description of the servlet.


* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}

DeleteBookServlet.java
package onlinelibrary.allservlets;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Vector;
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 onlinelibrary.beans.Book;
import onlinelibrary.util.DBConnection;
import java.util.logging.Level;
import java.util.logging.Logger;
public class DeleteBookServlet extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
Online Library Management System 41

* @param response servlet response


* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setHeader("Cache-Control","no-cache,no-store,must-revalidate");//HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
response.setContentType("text/html;charset=UTF-8");
if (request.getSession(false).getAttribute("user")==null){
response.sendRedirect("/OnlineLibrary");
return;
}
PrintWriter out = response.getWriter();
HttpSession session = request.getSession(false);
if(session==null){
response.sendRedirect("index.jsp");
return;
}
try {
Vector<Book> books =(Vector<Book>)session.getAttribute("books");
String strRecno= request.getParameter("recno");
Integer recno =null;
if(strRecno.equals(""))
recno = books.size()-1;
else
recno = Integer.parseInt(strRecno)-1;
Integer bookid = books.get(recno).getBookid();
String strSQL = "delete from bookmaster where bookid="+bookid;
Connection conn =DBConnection.getConnection();
Online Library Management System 42

Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,


ResultSet.CONCUR_UPDATABLE);
stmt.executeUpdate(strSQL);
books.removeElementAt(recno);
request.setAttribute("updatemsg", "Record [Bookid: "+ bookid+" ] deleted from the database");
request.setAttribute("books", books);
session.removeAttribute("books");
this.getServletContext().getRequestDispatcher("/office/searchbookresult.jsp").forward(request,
response);
stmt.close();
conn.close();
}
catch(Exception e){
Logger.getLogger(SearchBookServlet.class.getName()).log(Level.SEVERE, null, e);
request.setAttribute("updatemsg", "Unable to delete the record, Error: " + e.toString() + ", Please
check the logfile for details");
this.getServletContext().getRequestDispatcher("/office/searchbookresult.jsp").forward(request,
response);
}
finally {
out.close();
}
}
}

IssueBookServlet.java
package onlinelibrary.allservlets;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
Online Library Management System 43

import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
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 onlinelibrary.beans.Book;
import onlinelibrary.beans.Transaction;
import onlinelibrary.beans.UserMaster;
import onlinelibrary.util.DBConnection;
public class IssueBookServlet extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
Connection conn=null;
try {
System.out.println("U have called me");
HttpSession session = request.getSession(false);
Book book = (Book)session.getAttribute("selectedbook");
String cardno = (String)session.getAttribute("cardno");
Integer bookid = book.getBookid();
Online Library Management System 44

/*
* insert issue record into the transaction table
* update member record reduce bcoun by 1
* update book table set isavailable field to false
*/
conn = DBConnection.getConnection();
conn.setAutoCommit(false);
String strSQL1 = "insert into transaction (TransactionId, CardNo, BookId, IssueDate, ReturnDate
,UserId)" +
" values(?,?,?,?,?,?)";
String transactionid = this.getNextTransactionId(conn);
PreparedStatement pstmt1 = conn.prepareStatement(strSQL1,
ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
String issuedate = new SimpleDateFormat("dd/MM/yyyy").format(new java.util.Date());
String userid = ((UserMaster)session.getAttribute("user")).getUserid();
pstmt1.setString(1, transactionid);
pstmt1.setString(2, cardno);
pstmt1.setInt(3, bookid);
pstmt1.setString(4, issuedate);
pstmt1.setString(5, "NR");
pstmt1.setString(6, userid);

String strSQL2 = "update member set bcount=bcount-1 where CardNo=?";


PreparedStatement pstmt2 = conn.prepareStatement(strSQL2,
ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
pstmt2.setString(1, cardno);
String strSQL3 = "update bookmaster set IsAvailable=? where BookId=?";
PreparedStatement pstmt3 = conn.prepareStatement(strSQL3,
ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
pstmt3.setBoolean(1, false);
pstmt3.setInt(2, bookid);
pstmt1.executeUpdate();
pstmt2.executeUpdate();
Online Library Management System 45

pstmt3.executeUpdate();
conn.commit();
conn.setAutoCommit(true);
session.removeAttribute("recno");
session.removeAttribute("selectedbook");
session.removeAttribute("cardno");
Transaction transaction = new Transaction();
transaction.setTransactionid(transactionid);
transaction.setBook(book);
transaction.setType("BOOK ISSUE");
transaction.setCardno(cardno);
transaction.setIssuedate(issuedate);
transaction.setUser(userid);
transaction.setSuccess(true);
request.setAttribute("transaction", transaction);
this.getServletContext().getRequestDispatcher("/office/transactionend.jsp").forward(request,
response);
}
catch (Exception ex) {
Transaction transaction = new Transaction();
transaction.setSuccess(false);
request.setAttribute("transaction",transaction) ;
this.getServletContext().getRequestDispatcher("/office/transactionend.jsp").forward(request,
response);
Logger.getLogger(IssueBookServlet.class.getName()).log(Level.SEVERE, null, ex);
}
finally {
out.close();
}
}
private String getNextTransactionId(Connection conn) throws Exception{
String nextid = "";
Online Library Management System 46

/****************************/
String nextcardno="";
/*
* SELECT bookmaster.BookId, bookmaster.Title, bookmaster.DOP
FROM bookmaster
WHERE (((Year([DOP]))='2008'));
*
*/
String thisyear = new SimpleDateFormat("yyyy").format(new Date());
String strSQL ="SELECT TransactionId FROM transaction WHERE
Year([IssueDate])='"+thisyear+"' order by TransactionId";
PreparedStatement pstmt = conn.prepareStatement(strSQL,
ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet rs = pstmt.executeQuery();
if(!rs.last()){
nextid = "T/"+thisyear.substring(2)+"/"+"00001";
return nextid;
}
String lastid = rs.getString("TransactionId");
//System.out.println("Last Card No: " + lastcardno);
int nextno = Integer.parseInt(lastid.substring(5))+1;
//System.out.println("Last Card No: " + lastcardno + " next no: " + nextno);
if(nextno<10)
nextid="T/"+thisyear.substring(2)+"/0000"+nextno;
else if(nextno<100)
nextid="T/"+thisyear.substring(2)+"/000"+nextno;
else if(nextno<1000)
nextid="T/"+thisyear.substring(2)+"/00"+nextno;
else if(nextno<10000)
nextid="T/"+thisyear.substring(2)+"/0"+nextno;
else if(nextno<100000)
nextid="T/"+thisyear.substring(2)+"/"+nextno;
Online Library Management System 47

else
throw new Exception ("Transaction ID Overflow...");
pstmt.close();
return nextid;
/****************************/
}
}

LoginServlet.java
package onlinelibrary.allservlets;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
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 onlinelibrary.beans.Member;
import onlinelibrary.beans.UserMaster;
import onlinelibrary.util.DBConnection;
import onlinelibrary.util.FTPasswordService;
public class LoginServlet extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
Online Library Management System 48

*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
response.setHeader("Cache-Control","no-cache,no-store,must-revalidate");//HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
PrintWriter out = response.getWriter();
try {
String userid = request.getParameter("textfieldUserId");
String password = request.getParameter("textfieldPassword");
password = new FTPasswordService().encrypt(password);
Connection conn = DBConnection.getConnection();
PreparedStatement pstmt = null;
Integer usertype=0;//for holding usertype
//System.out.println("$$$: " + request.getParameter("radiobutton"));
if (Boolean.parseBoolean(request.getParameter("radiobutton"))){
pstmt = conn.prepareStatement("select CardNo, FirstName, LastName, Road, " +
"PIN, City,Mobile, EMail, Sex, Password, BCount, DOJ, " +
"DOB from member where CardNo=? and Password=? ",
ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
usertype = 1;
}
else{
pstmt = conn.prepareStatement("select UserId, Password, UserName, Type from usermaster
where UserId=? and Password=? ",ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
usertype=2;
}
System.out.println("Usertype: " + usertype);
pstmt.setString(1, userid);
pstmt.setString(2, password);
Online Library Management System 49

ResultSet rs= pstmt.executeQuery();


rs.last();
int rc = rs.getRow();
if(rc==0){
//login failed...redirect to the login page...
//System.out.println(" U Got Me Here ");
request.setAttribute("logininfo", "Invalid UserID/Password");
this.getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
return;
}
//otherwose login successfull.
//rs.first();//move the reseltset to the first record,obviously there is only one record.
HttpSession session = request.getSession(true);
session.setAttribute("usertype", usertype);
if(usertype==1){
//library member
Member member = new Member();
member.setCardno(rs.getString("CardNo"));
member.setDob(rs.getString("DOB"));
member.setDoj(rs.getString("DOJ"));
member.setEmail(rs.getString("EMail"));
member.setFirstname(rs.getString("FirstName"));
member.setLastname(rs.getString("LastName"));
member.setMobile(rs.getString("Mobile"));
member.setPassword(password);
member.setPin(rs.getString("PIN"));
member.setCity(rs.getString("City"));
member.setRoad(rs.getString("Road"));
member.setSex(rs.getBoolean("Sex"));
member.setBcount(rs.getInt("BCount"));
session.setAttribute("user", member);
Online Library Management System 50

System.out.println("Member Set To session ");


this.getServletContext().getRequestDispatcher("/office/memberhome.jsp").forward(request,
response);
}
else{
//library office user
System.out.println("U got me here!!!!!");
UserMaster usermaster = new UserMaster();
usermaster.setUserid(rs.getString("UserId"));
usermaster.setPassword(rs.getString("Password"));
usermaster.setUsername(rs.getString("UserName"));
usermaster.setType(rs.getInt("Type"));
session.setAttribute("user", usermaster);
this.getServletContext().getRequestDispatcher("/office/officehome.jsp").forward(request,
response);
}
}
catch(Exception e){
System.out.print("error: " + e.toString());
log(e.toString());
}
finally {
out.close();
}
}

MemberOperationControllerServlet.java
package onlinelibrary.allservlets;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
Online Library Management System 51

import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
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 onlinelibrary.beans.Member;
import onlinelibrary.util.DBConnection;

public class MemberOperationControllerServlet extends HttpServlet {


/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected Member getMember(HttpServletRequest request, String oprtype){
Member member = new Member();
HttpSession session = request.getSession(false);
if(oprtype.equals("2")){ //for updation get and set the cardno
//session.getAttribute()
if(Integer.parseInt(session.getAttribute("usertype").toString())==2)
member.setCardno(request.getParameter("cardno"));
else
member.setCardno(((Member)request.getSession(false).getAttribute("user")).getCardno());
}
member.setFirstname(request.getParameter("firstname"));
member.setLastname(request.getParameter("lastname"));
Online Library Management System 52

member.setRoad(request.getParameter("road"));
member.setCity(request.getParameter("city"));
member.setPin(request.getParameter("pin"));
member.setEmail(request.getParameter("email"));
member.setMobile(request.getParameter("mobile"));
member.setDob(request.getParameter("dob"));
member.setDoj(request.getParameter("doj"));
if(request.getParameter("sex").equals("male"))
member.setSex(true);
else
member.setSex(false);
member.setBcount(3);
return member;
}
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
//System.out.println("Controller Servlet Called: oprtype: " + request.getParameter("oprtype"));
Connection conn=null;
try {
conn = DBConnection.getConnection();
} catch (Exception ex) {
response.sendRedirect("index.jsp");
Logger.getLogger(MemberOperationControllerServlet.class.getName()).log(Level.SEVERE, null,
ex);
}
String oprtype = request.getParameter("oprtype");
if (oprtype.equals("1")){//insert member
try{
Member member = this.getMember(request,oprtype);
Online Library Management System 53

member.insertMember(conn);
request.setAttribute("insmsg", "Record Inserted Successfully: Member Card No: " +
member.getCardno() + " password: " + member.getPassword());
this.getServletContext().getRequestDispatcher("/office/membermaster.jsp").forward(request,
response);
}
catch (Exception ex) {
ex.printStackTrace(System.out);
request.setAttribute("insmsg", "Unable to complete insert/update operation for " + ex.toString() +
" view log for details");
this.getServletContext().getRequestDispatcher("/office/membermaster.jsp").forward(request,
response);
Logger.getLogger(MemberOperationControllerServlet.class.getName()).log(Level.SEVERE, null,
ex);
return;
}
}

else if(oprtype.equals("2")){ //update member


try{
Member amember = this.getMember(request, oprtype);
amember.updateMember(conn);
Vector<Member>members=
(Vector<Member>)request.getSession(false).getAttribute("updt_members");
if(members==null){
request.setAttribute("updatemsg", "Unable to perform update for Record [Card No: "+
amember.getCardno() +" ]");
this.getServletContext().getRequestDispatcher("/office/searchmember.jsp").forward(request,
response);
return;
}
Integer strRecno =(Integer) request.getSession(false).getAttribute("updt_recno");
// System.out.println("RecNo: " + strRecno);
Integer recno =null;
if(strRecno==null)
Online Library Management System 54

recno = members.size();
else
recno = strRecno;
amember.setBlocked(members.get(recno-1).isBlocked());
members.setElementAt(amember, recno-1);
request.getSession().removeAttribute("updt_members");
request.getSession().removeAttribute("updt_recno");
request.setAttribute("members", members);
request.setAttribute("recno", recno);
request.setAttribute("updatemsg", "Record [Card No: "+ amember.getCardno() +" ] Updated
Successfully ");

this.getServletContext().getRequestDispatcher("/office/searchmemberresult.jsp").forward(request,
response);
}
catch (Exception ex) {
request.setAttribute("searchmsg", "Unable to complete update operation for " + ex.toString() +
" view log for details");
this.getServletContext().getRequestDispatcher("/office/searchmember.jsp").forward(request,
response);
Logger.getLogger(MemberOperationControllerServlet.class.getName()).log(Level.SEVERE,
null, ex);
return;
}
}
else if(oprtype.equals("3")){
try {
//reset password for member
Vector<Member> members = (Vector<Member>)
request.getSession(false).getAttribute("members");
//Member amember=members.get(index)
if (members == null) {
request.setAttribute("updatemsg", "Unable to reset Password...");
this.getServletContext().getRequestDispatcher("/office/searchmember.jsp").forward(request,
response);
Online Library Management System 55

return;
}
String strRecno = request.getParameter("recno");
// System.out.println("RecNo: " + strRecno);
Integer recno = null;
if (strRecno.equals("")) {
recno = members.size();
} else {
recno = Integer.parseInt(strRecno);

}
System.out.println("RecNo: " + recno + ", Member Card No: " + members.get(recno-
1).getCardno());
//String newpasword = new FTPasswordService().generatePassword();
//String encryppassword = new FTPasswordService().encrypt(newpasword);
Member amember = members.get(recno-1);
amember.resetPassword(conn);
request.setAttribute("members", members);
request.setAttribute("recno", recno);
request.setAttribute("updatemsg", "Password Reset Done For [Card No: "+ amember.getCardno()
+" ], New Password : " + amember.getPassword());

this.getServletContext().getRequestDispatcher("/office/searchmemberresult.jsp").forward(request,
response);

} catch (Exception ex) {


request.setAttribute("searchmsg", "Unable to reset pasword, Due To: " + ex.toString() + " view
log for details");
this.getServletContext().getRequestDispatcher("/office/searchmember.jsp").forward(request,
response);
Logger.getLogger(MemberOperationControllerServlet.class.getName()).log(Level.SEVERE, null,
ex);
}
//String strSQL =
Online Library Management System 56

}
else if(oprtype.equals("4") || oprtype.equals("5")){ //search member operations
try{
String strSQL ="";
if(oprtype.equals("4")){
String cardno = request.getParameter("cardno").trim();
String firstname = request.getParameter("firstname");
String lastname = request.getParameter("lastname");
if(cardno!=null && !cardno.equals(""))
strSQL = "select * from member where CardNo='"+cardno+"'";
else{
firstname = firstname.equals("")?"%":firstname+"%";
lastname = lastname.equals("")?"%":lastname+"%";
strSQL = "select * from member where FirstName like '"+firstname+"' and LastName like '"
+lastname +"'" ;
}
}
else if(oprtype.equals("5"))
strSQL = "select * from member where Blocked=true";
Vector<Member> members = Member.getAllMembers(strSQL,conn);
if(members.size()==0){
request.setAttribute("searchmsg", "No Record Found...");
this.getServletContext().getRequestDispatcher("/office/searchmember.jsp").forward(request,
response);
}
else{
request.setAttribute("members", members);

this.getServletContext().getRequestDispatcher("/office/searchmemberresult.jsp").forward(request,
response);
}
}
catch (Exception ex) {
Online Library Management System 57

request.setAttribute("searchmsg", "Unable to complete search operation for " + ex.toString() +


" view log for details");
this.getServletContext().getRequestDispatcher("/office/searchmember.jsp").forward(request,
response);
Logger.getLogger(MemberOperationControllerServlet.class.getName()).log(Level.SEVERE,
null, ex);
return;
}
}//end of choice 4 or 5
else if(oprtype.equals("10")){
try {
//member profile update
Member amember = this.getMember(request, "2");
amember.updateMember(conn);
Member sessionmember =(Member)request.getSession(false).getAttribute("user");
amember.setPassword(sessionmember.getPassword());
amember.setBcount(sessionmember.getBcount());
request.getSession(false).setAttribute("user", amember);
request.setAttribute("genmsg", "Record [Card No: "+ amember.getCardno() +" ] Updated
Successfully ");
this.getServletContext().getRequestDispatcher("/office/memberhome.jsp").forward(request,
response);
} catch (Exception ex) {
Logger.getLogger(MemberOperationControllerServlet.class.getName()).log(Level.SEVERE, null,
ex);
request.setAttribute("genmsg", "Record Updation Failed");
this.getServletContext().getRequestDispatcher("/office/memberhome.jsp").forward(request,
response);
}
}
}

MenuDriverServlet.java
package onlinelibrary.allservlets;
import java.io.IOException;
Online Library Management System 58

import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class MenuDriverServlet extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
if (request.getSession(false).getAttribute("user")==null){
response.sendRedirect("/OnlineLibrary");
return;
}
response.setHeader("Cache-Control","no-cache,no-store,must-revalidate");//HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
String menuno = request.getParameter("menuno");
if (menuno.equals("home"))
this.getServletContext().getRequestDispatcher("/office/officehome.jsp").forward(request,
response);
if (menuno.equals("memhome"))
this.getServletContext().getRequestDispatcher("/office/memberhome.jsp").forward(request,
response);
else if (menuno.equals("b1"))
Online Library Management System 59

this.getServletContext().getRequestDispatcher("/office/bookmaster.jsp").forward(request,
response);
else if(menuno.equals("b2"))
this.getServletContext().getRequestDispatcher("/office/searchbook.jsp").forward(request,
response);
else if(menuno.equals("u1"))
this.getServletContext().getRequestDispatcher("/office/updatebook.jsp").forward(request,
response);
else if(menuno.equals("m1"))
this.getServletContext().getRequestDispatcher("/office/membermaster.jsp").forward(request,
response);
else if(menuno.equals("m2"))
this.getServletContext().getRequestDispatcher("/office/searchmember.jsp").forward(request,
response);
else if(menuno.equals("view"))
this.getServletContext().getRequestDispatcher("/office/viewmember.jsp").forward(request,
response);
else if(menuno.equals("updatemember"))
this.getServletContext().getRequestDispatcher("/office/updatemember.jsp").forward(request,
response);
else if(menuno.equals("issuebook"))
this.getServletContext().getRequestDispatcher("/office/issuebookfinal.jsp").forward(request,
response);
else if(menuno.equals("takecard"))
this.getServletContext().getRequestDispatcher("/office/takecardforissue.jsp").forward(request,
response);
else if(menuno.equals("returnbook"))
this.getServletContext().getRequestDispatcher("/office/takecardforreturn.jsp").forward(request,
response);
else if(menuno.equals("dbfr"))
this.getServletContext().getRequestDispatcher("/office/displaybooksforreturn.jsp").forward(request,
response);
else if(menuno.equals("dmem"))
this.getServletContext().getRequestDispatcher("/office/defaultercards.jsp").forward(request,
response);
else if(menuno.equals("cpwd"))
Online Library Management System 60

this.getServletContext().getRequestDispatcher("/office/changepassword.jsp").forward(request,
response);
else if(menuno.equals("selftrans"))
this.getServletContext().getRequestDispatcher("/office/membertransactions.jsp").forward(request,
response);
else if(menuno.equals("booksnotret"))

this.getServletContext().getRequestDispatcher("/office/booksnotreturnedbymember.jsp").forward(request,
response);
else if(menuno.equals("updatememprofile"))
this.getServletContext().getRequestDispatcher("/office/updatememberprofile.jsp").forward(request,
response);
else if(menuno.equals("logoutoffice")){
HttpSession session = request.getSession(false);
session.removeAttribute("user");
session.invalidate();
response.sendRedirect("/OnlineLibrary");
}
}

ReturnBookServlet.java
package onlinelibrary.allservlets;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class MenuDriverServlet extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
Online Library Management System 61

* @throws ServletException if a servlet-specific error occurs


* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
if (request.getSession(false).getAttribute("user")==null){
response.sendRedirect("/OnlineLibrary");
return;
}
response.setHeader("Cache-Control","no-cache,no-store,must-revalidate");//HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
String menuno = request.getParameter("menuno");
if (menuno.equals("home"))
this.getServletContext().getRequestDispatcher("/office/officehome.jsp").forward(request,
response);
if (menuno.equals("memhome"))
this.getServletContext().getRequestDispatcher("/office/memberhome.jsp").forward(request,
response);
else if (menuno.equals("b1"))
this.getServletContext().getRequestDispatcher("/office/bookmaster.jsp").forward(request,
response);
else if(menuno.equals("b2"))
this.getServletContext().getRequestDispatcher("/office/searchbook.jsp").forward(request,
response);
else if(menuno.equals("u1"))
this.getServletContext().getRequestDispatcher("/office/updatebook.jsp").forward(request,
response);
else if(menuno.equals("m1"))
this.getServletContext().getRequestDispatcher("/office/membermaster.jsp").forward(request,
response);
else if(menuno.equals("m2"))
Online Library Management System 62

this.getServletContext().getRequestDispatcher("/office/searchmember.jsp").forward(request,
response);
else if(menuno.equals("view"))
this.getServletContext().getRequestDispatcher("/office/viewmember.jsp").forward(request,
response);
else if(menuno.equals("updatemember"))
this.getServletContext().getRequestDispatcher("/office/updatemember.jsp").forward(request,
response);
else if(menuno.equals("issuebook"))
this.getServletContext().getRequestDispatcher("/office/issuebookfinal.jsp").forward(request,
response);
else if(menuno.equals("takecard"))
this.getServletContext().getRequestDispatcher("/office/takecardforissue.jsp").forward(request,
response);
else if(menuno.equals("returnbook"))
this.getServletContext().getRequestDispatcher("/office/takecardforreturn.jsp").forward(request,
response);
else if(menuno.equals("dbfr"))
this.getServletContext().getRequestDispatcher("/office/displaybooksforreturn.jsp").forward(request,
response);
else if(menuno.equals("dmem"))
this.getServletContext().getRequestDispatcher("/office/defaultercards.jsp").forward(request,
response);
else if(menuno.equals("cpwd"))
this.getServletContext().getRequestDispatcher("/office/changepassword.jsp").forward(request,
response);
else if(menuno.equals("selftrans"))
this.getServletContext().getRequestDispatcher("/office/membertransactions.jsp").forward(request,
response);
else if(menuno.equals("booksnotret"))

this.getServletContext().getRequestDispatcher("/office/booksnotreturnedbymember.jsp").forward(request,
response);
else if(menuno.equals("updatememprofile"))
this.getServletContext().getRequestDispatcher("/office/updatememberprofile.jsp").forward(request,
response);
else if(menuno.equals("logoutoffice")){
Online Library Management System 63

HttpSession session = request.getSession(false);


session.removeAttribute("user");
session.invalidate();
response.sendRedirect("/OnlineLibrary");
}
}

SaveBookServlet.java
package onlinelibrary.allservlets;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.NamingException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import onlinelibrary.beans.Book;
import onlinelibrary.util.DBConnection;
public class SaveBookServlet extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
Online Library Management System 64

protected void processRequest(HttpServletRequest request, HttpServletResponse response)


throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
if (request.getSession(false).getAttribute("user")==null){
response.sendRedirect("/OnlineLibrary");
return;
}
response.setHeader("Cache-Control","no-cache,no-store,must-revalidate");//HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
PrintWriter out = response.getWriter();
Connection conn=null;
try {
Book abook = new Book();
abook.setTitle(request.getParameter("title"));
abook.setAuthor1(request.getParameter("author1"));
abook.setAuthor2(request.getParameter("author2"));
abook.setAuthor3(request.getParameter("author3"));
abook.setPublisher(request.getParameter("publisher"));
abook.setSubject(request.getParameter("subject"));

abook.setPrice(Double.parseDouble(request.getParameter("price")));
abook.setDop(request.getParameter("dop"));
abook.setIsavailable(true);
abook.setIsbn(request.getParameter("isbn"));
conn = DBConnection.getConnection();
abook.insertIntoDatabase(conn);
request.setAttribute("bookid", abook.getBookid());
request.setAttribute("insmsg", "Record Inserted Successfully...");
this.getServletContext().getRequestDispatcher("/office/bookmaster.jsp").forward(request,
response);
Online Library Management System 65

}
catch(Exception e){
request.setAttribute("insmsg", "Record Insertion Failed...Pls view Logfile for
details..."+e.toString());
Logger.getLogger(SaveBookServlet.class.getName()).log(Level.SEVERE, null, e);
this.getServletContext().getRequestDispatcher("/office/bookmaster.jsp").forward(request,
response);
}
finally {
out.close();
try {
conn.close();
} catch (SQLException ex) {
Logger.getLogger(SaveBookServlet.class.getName()).log(Level.SEVERE, null, ex);
}
}
}

SearchBookServlet.java
package onlinelibrary.allservlets;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
Online Library Management System 66

import javax.servlet.http.HttpServletResponse;
import onlinelibrary.beans.Book;
import onlinelibrary.util.DBConnection;
public class SearchBookServlet extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
if (request.getSession(false).getAttribute("user")==null){
response.sendRedirect("/OnlineLibrary");
return;
}
response.setHeader("Cache-Control","no-cache,no-store,must-revalidate");//HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
PrintWriter out = response.getWriter();
try {
String strbookid = request.getParameter("bookid").trim();
String title = request.getParameter("title");
String subject = request.getParameter("subject");
String author1 = request.getParameter("author1");
String author2 = request.getParameter("author2");
String author3 = request.getParameter("author3");
//System.out.println("author3");
//out.println(bookid + "," + subject+ "," + author1 + "," + author2 + ","+author3);
Online Library Management System 67

String strSQL="";
if(strbookid!=null && !strbookid.equals("")){
Integer bookid = Integer.parseInt(strbookid);
strSQL ="select BookId, Title, Subject, Author1, Author2, Author3, Publisher, isAvailable, Price,
DOP, ISBN from bookmaster where bookid ="+bookid;
}
else{
title = ((title==null) || title.equals(""))?"%":title;
subject = subject.equals("")?"%":subject;
author1 = author1.equals("")?"%":author1;
author2 = author2.equals("")?"%":author2;
author3 = author3.equals("")?"%":author3;
strSQL = "select BookId, Title, Subject, Author1, Author2, Author3, Publisher, isAvailable, Price,
DOP, ISBN from bookmaster " +
"where title like '"+ title +"%' and subject like '"+subject+"%' and author1 like
'"+author1+"%' and author2 like '"+author2+"%' and author3 like '"+author3+"%' order by bookid";
}
Connection conn = DBConnection.getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(strSQL);
Boolean found = false;
Vector<Book>books = new Vector<Book>();
while(rs.next()){
found = true;
Book abook = new Book();
abook.setBookid(rs.getInt("BookId"));
abook.setTitle(rs.getString("Title"));
abook.setSubject(rs.getString("Subject"));
abook.setPublisher(rs.getString("Publisher"));
abook.setPrice(rs.getDouble("Price"));
abook.setAuthor1(rs.getString("Author1"));
abook.setAuthor2(rs.getString("Author2"));
Online Library Management System 68

abook.setAuthor3(rs.getString("Author3"));
abook.setDop(rs.getString("DOP"));
abook.setIsavailable(rs.getBoolean("isAvailable"));
abook.setIsbn(rs.getString("ISBN"));
books.add(abook);
}
if(!found){
//return to the search page...
request.setAttribute("searchmsg", "No Record Found with the given serach criteria");
this.getServletContext().getRequestDispatcher("/office/searchbook.jsp").forward(request,
response);
}
else{
//display the selected found records...
request.setAttribute("books", books);
this.getServletContext().getRequestDispatcher("/office/searchbookresult.jsp").forward(request,
response);
}
}
catch(Exception ex) {
Logger.getLogger(SearchBookServlet.class.getName()).log(Level.SEVERE, null, ex);
request.setAttribute("searchmsg", "Unable to perform search, error: " + ex.toString() + " refer log
file for details ");
this.getServletContext().getRequestDispatcher("/office/searchbook.jsp").forward(request,
response);
}
finally {
out.close();
}
}

TestServlet.java
package onlinelibrary.allservlets;
Online Library Management System 69

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import onlinelibrary.util.DBConnection;
public class TestServlet extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
Connection conn = DBConnection.getConnection();

Statement stmt = conn.createStatement();


ResultSet rs = stmt.executeQuery("select * from usermaster");
while(rs.next()){
System.out.println("UserId: " + rs.getString("UserId") + " Name: " +
rs.getString("UserName"));
}
Online Library Management System 70

rs.close();
stmt.close();
conn.close();
/* TODO output your page here
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet TestServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet TestServlet at " + request.getContextPath () + "</h1>");
out.println("</body>");
out.println("</html>");
*/
}
catch(Exception e){
}
finally {
out.close();
}
}

UnblockMemberServlet.java
package onlinelibrary.allservlets;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import onlinelibrary.beans.Member;
import onlinelibrary.util.DBConnection;
public class UnblockMemberServlet extends HttpServlet {
Online Library Management System 71

/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
Connection conn =null;
Vector<Member> members=(Vector<Member>) request.getSession().getAttribute("members");
try {
conn = DBConnection.getConnection();
String strRecno =request.getParameter("recno");
Integer recno =null;
if(strRecno.equals(""))
recno = members.size();
else
recno = Integer.parseInt(strRecno);
request.setAttribute("recno", recno);
Member amember = members.get(recno-1);
if (amember.isBlocked()){
amember.unBlockMember(conn);
amember.setBlocked(false);
request.setAttribute("updatemsg", "Member [ Card No: " + amember.getCardno() +" ] has been
unblocked ");
request.setAttribute("members", members);
//request.getSession().removeAttribute("members");

this.getServletContext().getRequestDispatcher("/office/searchmemberresult.jsp").forward(request,
response);
return;
}
else{
request.setAttribute("updatemsg", "Member [ Card No: " + amember.getCardno() +" ] already
unblocked...");
request.setAttribute("members", members);
//request.getSession().removeAttribute("members");
this.getServletContext().getRequestDispatcher("/office/searchmemberresult.jsp").forward(request,
response);
return;
}
}
catch(Exception ex){
request.setAttribute("updatemsg", "Unable block member, for " + ex.toString() + " view log for
details");
request.setAttribute("members", members);
this.getServletContext().getRequestDispatcher("/office/searchmemberresult.jsp").forward(request,
response);
Logger.getLogger(MemberOperationControllerServlet.class.getName()).log(Level.SEVERE, null,
ex);
Online Library Management System 72

}
finally {
out.close();
try {
conn.close();
} catch (SQLException ex) {
Logger.getLogger(BlockMemberServlet.class.getName()).log(Level.SEVERE, null, ex);
}
}
}

UpdateBookServlet.java
package onlinelibrary.allservlets;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import onlinelibrary.beans.Book;
import onlinelibrary.util.DBConnection;
public class UpdateBookServlet extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
if (request.getSession(false).getAttribute("user")==null){
response.sendRedirect("/OnlineLibrary");
return;
}
response.setHeader("Cache-Control","no-cache,no-store,must-revalidate");//HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
PrintWriter out = response.getWriter();
Connection conn=null;
try {
Book abook = new Book();
abook.setBookid(Integer.parseInt(request.getParameter("bookid")));
abook.setTitle(request.getParameter("title"));
abook.setAuthor1(request.getParameter("author1"));
abook.setAuthor2(request.getParameter("author2"));
abook.setAuthor3(request.getParameter("author3"));
abook.setPublisher(request.getParameter("publisher"));
Online Library Management System 73

abook.setSubject(request.getParameter("subject"));
abook.setPrice(Double.parseDouble(request.getParameter("price")));
abook.setDop(request.getParameter("dop"));
//abook.setIsavailable(true);
abook.setIsbn(request.getParameter("isbn"));
conn = DBConnection.getConnection();
abook.updateBook(conn);
conn.close();
Vector<Book> books = (Vector<Book>) request.getSession(false).getAttribute("books");
Integer recno = Integer.parseInt(request.getParameter("recno"));
books.removeElementAt(recno);
books.insertElementAt(abook, recno);
request.setAttribute("books", books);
request.setAttribute("updatemsg", "Record Updated Successfully...");
request.getSession(false).removeAttribute("books");
this.getServletContext().getRequestDispatcher("/office/searchbookresult.jsp").forward(request,
response);
}
catch(Exception e){
request.setAttribute("updatemsg", "Record Insertion Failed...Pls view Logfile for
details..."+e.toString());
Logger.getLogger(SaveBookServlet.class.getName()).log(Level.SEVERE, null, e);
this.getServletContext().getRequestDispatcher("/office/bookmaster.jsp").forward(request,
response);
}
finally {
out.close();
}
}

JAVA DOC
Class Book
java.lang.Object

 onlinelibrary.beans.Book

Modifier and Type Method and Description

java.lang.String getAuthor1()

java.lang.String getAuthor2()

java.lang.String getAuthor3()

java.lang.Integer getBookid()

java.lang.String getDop()

java.lang.Boolean getIsavailable()

java.lang.String getIsbn()

java.lang.Integer getNextBookId(java.sql.Connection conn)


Online Library Management System 74

java.lang.Double getPrice()

java.lang.String getPublisher()

java.lang.String getSubject()

java.lang.String getTitle()

void insertIntoDatabase(java.sql.Connection conn)

void setAuthor1(java.lang.String author1)

void setAuthor2(java.lang.String author2)

void setAuthor3(java.lang.String author3)

void setBookid(java.lang.Integer bookid)

void setDop(java.lang.String dop)

void setIsavailable(java.lang.Boolean isavailable)

void setIsbn(java.lang.String isbn)

void setPrice(java.lang.Double price)

void setPublisher(java.lang.String publisher)

void setSubject(java.lang.String subject)

void setTitle(java.lang.String title)

void updateBook(java.sql.Connection conn)

Methods inherited from class java.lang.Object


clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait,
wait

Constructor Detail

 Book
public Book()

 Method Detail

 getAuthor1 public java.lang.String getAuthor1()


 setAuthor1 public void setAuthor1(java.lang.String author1)
 getAuthor2 public java.lang.String getAuthor2()
 setAuthor2 public void setAuthor2(java.lang.String author2)
 getAuthor3 public java.lang.String getAuthor3()
 setAuthor3 public void setAuthor3(java.lang.String author3)
 getBookid public java.lang.Integer getBookid()
 setBookid public void setBookid(java.lang.Integer bookid)
Online Library Management System 75

 getDop public java.lang.String getDop()


 setDop public void setDop(java.lang.String dop)
 getIsavailable public java.lang.Boolean getIsavailable()
 setIsavailable public void setIsavailable(java.lang.Boolean isavailable)
 getIsbn public java.lang.String getIsbn()
 setIsbn public void setIsbn(java.lang.String isbn)
 getPrice public java.lang.Double getPrice()
 setPrice public void setPrice(java.lang.Double price)
 getPublisher public java.lang.String getPublisher()
 setPublisher public void setPublisher(java.lang.String publisher)
 getSubject public java.lang.String getSubject()
 setSubject public void setSubject(java.lang.String subject)
 getTitle public java.lang.String getTitle()
 setTitle public void setTitle(java.lang.String title)

 getNextBookId public java.lang.Integer getNextBookId(java.sql.Connection conn)

 throws java.lang.Exception

 Throws: java.lang.Exception

 insertIntoDatabase public void insertIntoDatabase(java.sql.Connection conn)


 throws java.lang.Exception

 Throws: java.lang.Exception

 updateBook public void updateBook(java.sql.Connection conn)


 throws java.lang.Exception

 Throws: java.lang.Exception

Class Member

 java.lang.Object

 onlinelibrary.beans.Member

 Constructor Summary

Constructor and Description

Member()

 Method Summary

Modifier and Type Method and Description


Online Library Management System 76

void blockMember(java.sql.Connection conn)

void deleteMember(java.sql.Connection conn)

static getAllMembers(java.lang.String strSQL, java.sql.Connection conn)


java.util.Vector<Member>

java.lang.Integer getBcount()

java.lang.String getCardno()

java.lang.String getCity()

java.lang.String getDob()

java.lang.String getDoj()

java.lang.String getEmail()

java.lang.String getEncryptedpassword()

java.lang.String getFirstname()

java.lang.String getLastname()

java.lang.String getMobile()

java.lang.String getNextCardNo(java.sql.Connection conn)

java.lang.String getNextCardNo(java.sql.Connection conn, java.lang.String doj)

java.lang.String getPassword()

java.lang.String getPin()

java.lang.String getRoad()

java.lang.String getWhyblocked()

void insertMember(java.sql.Connection conn)

boolean isBlocked()

boolean isSex()

void resetPassword(java.sql.Connection conn)

void setBcount(java.lang.Integer bcount)

void setBlocked(boolean blocked)


Online Library Management System 77

void setCardno(java.lang.String cardno)

void setCity(java.lang.String city)

void setDob(java.lang.String dob)

void setDoj(java.lang.String doj)

void setEmail(java.lang.String email)

void setEncryptedpassword(java.lang.String encryptedpassword)

void setFirstname(java.lang.String firstname)

void setLastname(java.lang.String lastname)

void setMobile(java.lang.String mobile)

void setPassword(java.lang.String password)

void setPin(java.lang.String pin)

void setRoad(java.lang.String road)

void setSex(boolean sex)

void setWhyblocked(java.lang.String whyblocked)

void unBlockMember(java.sql.Connection conn)

void updateMember(java.sql.Connection conn)

 Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

 Member
public Member()

Method Detail

 isBlocked public boolean isBlocked()

 setBlocked public void setBlocked(boolean blocked)

 getWhyblocked public java.lang.String getWhyblocked()

 setWhyblocked public void setWhyblocked(java.lang.String whyblocked)

 getBcount public java.lang.Integer getBcount()


Online Library Management System 78

 setBcount public void setBcount(java.lang.Integer bcount)

 getCardno public java.lang.String getCardno()

 setCardno public void setCardno(java.lang.String cardno)

 getDob public java.lang.String getDob()

 setDob public void setDob(java.lang.String dob)

 getDoj public java.lang.String getDoj()

 setDoj public void setDoj(java.lang.String doj)

 getEmail public java.lang.String getEmail()

 setEmail public void setEmail(java.lang.String email)

 getFirstname public java.lang.String getFirstname()

 setFirstname public void setFirstname(java.lang.String firstname)

 getLastname public java.lang.String getLastname()

 setLastname public void setLastname(java.lang.String lastname)

 getMobile public java.lang.String getMobile()

 setMobile public void setMobile(java.lang.String mobile)

 getPassword public java.lang.String getPassword()

 setPassword public void setPassword(java.lang.String password)

 getPin public java.lang.String getPin()

 setPin public void setPin(java.lang.String pin)

 getCity public java.lang.String getCity()

 setCity public void setCity(java.lang.String city)

 getRoad public java.lang.String getRoad()

 setRoad public void setRoad(java.lang.String road)

 isSex public boolean isSex()

 setSex public void setSex(boolean sex)

 getNextCardNo public java.lang.String getNextCardNo(java.sql.Connection conn)

 throws java.lang.Exception

Throws: java.lang.Exception

 GetNextCardNo public java.lang.String getNextCardNo(java.sql.Connection conn,

 java.lang.String doj)

 throws java.lang.Exception

Throws: java.lang.Exception

 InsertMember public void insertMember(java.sql.Connection conn)

 throws java.lang.Exception

Throws: java.lang.Exception

 updateMember public void updateMember(java.sql.Connection conn)

 throws java.lang.Exception

Throws: java.lang.Exception
Online Library Management System 79

 deleteMember public void deleteMember(java.sql.Connection conn)

 throws java.lang.Exception

Throws: java.lang.Exception

 getAllMembers public static java.util.Vector<Member> getAllMembers(java.lang.String strSQL,

 java.sql.Connection conn)

 throws java.lang.Exception

Throws: java.lang.Exception

 blockMember public void blockMember(java.sql.Connection conn)

 throws java.lang.Exception

Throws: java.lang.Exception

 UnBlockMember public void unBlockMember(java.sql.Connection conn)

 throws java.lang.Exception

Throws: java.lang.Exception

 resetPassword public void resetPassword(java.sql.Connection conn)

 throws java.lang.Exception

Throws: java.lang.Exception

 GetEncryptedpassword public java.lang.String getEncryptedpassword()

 Returns: the encryptedpassword

 SetEncryptedpassword public void setEncryptedpassword(java.lang.String encryptedpassword)

Parameters: encryptedpassword - the encryptedpassword to set

Class Transaction

 java.lang.Object

 onlinelibrary.beans.Transaction

Constructor Summary

Constructor and Description

Transaction()

Method Summary

Modifier and Type Method and Description


Online Library Management System 80

Book getBook()

java.lang.String getCardno()

java.lang.String getIssuedate()

java.lang.String getReturndate()

java.lang.Boolean getSuccess()

java.lang.String getTransactionid()

java.lang.String getType()

java.lang.String getUser()

void setBook(Book book)

void setCardno(java.lang.String cardno)

void setIssuedate(java.lang.String issuedate)

void setReturndate(java.lang.String returndate)

void setSuccess(java.lang.Boolean success)

void setTransactionid(java.lang.String transactionid)

void setType(java.lang.String type)

void setUser(java.lang.String user)

 Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 Constructor Detail

 Transaction public Transaction()

 Method Detail

 GetSuccess public java.lang.Boolean getSuccess()

 SetSuccess public void setSuccess(java.lang.Boolean success)

 GetBook public Book getBook()

 SetBook public void setBook(Book book)

 GetCardno public java.lang.String getCardno()

 SetCardno public void setCardno(java.lang.String cardno)


Online Library Management System 81

 GetIssuedate public java.lang.String getIssuedate()

 SetIssuedate public void setIssuedate(java.lang.String issuedate)

 GetReturndate public java.lang.String getReturndate()

 SetReturndate public void setReturndate(java.lang.String returndate)

 GetTransactionid public java.lang.String getTransactionid()

 SetTransactionid public void setTransactionid(java.lang.String transactionid)

 GetType public java.lang.String getType()

 SetType public void setType(java.lang.String type)

 GetUser public java.lang.String getUser()

 SetUser public void setUser(java.lang.String user)

Class UserMaster

 java.lang.Object

 onlinelibrary.beans.UserMaster

Constructor Summary
Constructor and Description

UserMaster()

UserMaster(java.lang.String userid, java.lang.String password, java.lang.String username,


java.lang.Integer type)

Method Summary
Modifier and Type Method and Description

java.lang.String getPassword()

java.lang.Integer getType()

java.lang.String getUserid()

java.lang.String getUsername()

void setPassword(java.lang.String password)

void setType(java.lang.Integer type)

void setUserid(java.lang.String userid)

void setUsername(java.lang.String username)


Online Library Management System 82

 Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString,


wait, wait, wait

 Constructor Detail

 UserMaster public UserMaster()

 UserMaster public UserMaster(java.lang.String userid,


java.lang.String password,java.lang.String username,java.lang.Integer type)

 Method Detail

 GetPassword public java.lang.String getPassword()

 SetPassword public void setPassword(java.lang.String password)

 GetType public java.lang.Integer getType()

 SetType public void setType(java.lang.Integer type)

 GetUserid public java.lang.String getUserid()

 SetUserid public void setUserid(java.lang.String userid)

 GetUsername public java.lang.String getUsername()

 SetUsername public void setUsername(java.lang.String username)


Online Library Management System 83

Class Hierarchy

 java.lang.Object

 onlinelibrary.beans.Book (implements java.io.Serializable)


 onlinelibrary.util.DateUtils
 onlinelibrary.util.DBConnection
 onlinelibrary.util.FTPasswordService

 javax.servlet.GenericServlet (implements java.io.Serializable,


javax.servlet.Servlet, javax.servlet.ServletConfig)

 javax.servlet.http.HttpServlet
 onlinelibrary.allservlets.BlockMemberServlet
 onlinelibrary.allservlets.ChangePasswordServlet
 onlinelibrary.allservlets.DeleteBookServlet
 onlinelibrary.allservlets.IssueBookServlet
 onlinelibrary.allservlets.LoginServlet
 onlinelibrary.allservlets.MemberOperationControllerServlet
 onlinelibrary.allservlets.MenuDriverServlet
 onlinelibrary.allservlets.ReturnBookServlet
 onlinelibrary.allservlets.SaveBookServlet
 onlinelibrary.allservlets.SearchBookServlet
 onlinelibrary.allservlets.TestServlet
 onlinelibrary.allservlets.UnblockMemberServlet
 onlinelibrary.allservlets.UpdateBookServlet
o onlinelibrary.beans.Member (implements java.io.Serializable)
o onlinelibrary.beans.ReturnBookData
o onlinelibrary.beans.Transaction (implements java.io.Serializable)
o onlinelibrary.beans.UserMaster (implements java.io.Serializable)
o onlinelibrary.util.Validator
Online Library Management System 84

CODE EFFICIENCY

After running the code it will take more or less minimum time to execute. But it is not
sure that this code will be efficient in every circumstances like as large data handling, complex
query. Generally code efficiency can be measured by time complexity and space complexity of
the code. Time complexity is basically is the time to execute code that means run time. But the
unit of time complexity not in time because of different processors time. So it is measured in
number of times executions of loop. Space complexity is amount of space required to run the
code. To denote the time and space complexity some notations are used. ―Big-Oh‖ is one such
notation. Let f(n) and g(n) are two nonnegative functions. The function f(n) =O(g(n)) (read as f
of n equals big-oh of g of n) if there exists two constants c & n0 such that | f(n) |<=|g(n)| for all n
<=n0 f(n) will normally represent the computing time of some algorithm. When the computing
time of some algorithm is O(g(n)) that means it execution takes no more than a constant time
g(n), where n is a parameter which characterizes input/output.
In this project the order of time complexity is O(n), that means linier in time. Space
complexity of this algorithm is also O(n).

OPTIMIZATION OF CODE
Because of better efficiency, minimum execution time and storage code optimization is
done. In this project code optimization is done to save storage space and less execution time.
Primarily when code has been written the length of code is bigger. After optimization this code
becomes smaller and saves memory space. It also improves the execution time of the code.

VALIDATION CHECKS

Software testing is often referred to as verification and validation (V & V).Verification


refers to the set of activities that ensures the software correctly implements a specific function.
Validation refers to a different set of activities that ensures the software that has been built is
traceable to customer requirements.
Validation with respect to this software is basically depending on the requirement that
measures whether the software is performing or running well or not. It totally depends on the
customer requirements and testing strategies. We can ensure validation checking by performing
Unit Testing, Alpha Testing, Beta Testing etc.
Online Library Management System 85

TESTING
Software Testing is an empirical investigation conducted to provide stakeholders with
information about the quality of the product or service under test. Testing a program consists of
subjecting the program to a set of test inputs and observing if the program behaves as expected.
Following are some commonly used terms associated with testing.

 A Failure is a manifestation of an error. But a mere presence of error does not


lead to a failure.

 A Test case is the triplet [I, S, O], where I is the data input to the system, S is the
state of the system at which the data is input, and O is the expected of the system.

 A Test Suite is the set of all test cases with which a given software product is to
be tested.

The Testing process involves various types of testing. Each test type addresses a specific testing
requirement. The most common types of testing involved in the development process are:

 Unit Testing :
Unit Testing is testing of individual software components or modules. It is
typically done by the programmer and not by testers, as it requires detailed knowledge of
the internal program design and code.

 Incremental Integration Testing :


In Incremental integration testing continuous testing of an application is done as
new functionality is added. Application functionality and modules should be independent
enough to test separately. This testing is done by programmers or by testers.

 System Testing:
System testing is the testing of integrated modules to verify combined
functionality after integration and to check if it meets its requirements.

 Stress Testing :
In Stress testing System is stressed beyond its specifications to check how and
when it fails. The testing is performed under heavy load like putting large number beyond
storage capacity, complex database queries, continuous input to system or database load.
Online Library Management System 86

 Load Testing –
It is a performance testing to check system behavior under load. Testing an
application under heavy loads, such as testing of a web site under a range of loads to
determine at what point the system’s response time degrades or fails.

 Compatibility Testing –
Testing how well software performs in a particular hardware/software/operating
system/network environment and different combination s of above.

 Recovery Testing –
Recovery testing is the activity of testing how well the application is able to
recover from crashes, hardware failures and other similar problems. Recovery testing is
the forced failure of the software in a variety of ways to verify that recovery is properly
performed.

 Security Testing –
In security checking it is checked if the system can be penetrated by any hacking
way. It is checked how well the system protects against unauthorized internal or external
access and if system, database is safe from external attacks.

 Usability Testing –
It is user-friendliness check. In usability testing Application flow is tested. It is
checked if new user can understand the application easily. Proper help documented
whenever user stuck at any point. Basically system navigation is checked in this testing.

 Alpha Testing –
In house virtual user environment can be created for this type of testing. Testing is
done at the end of development. Still minor design changes may be made as a result of
such testing.

 Beta testing –
Beta Testing is typically done by end-users or others. It is the Final testing before
releasing application for commercial purpose.
Online Library Management System 87

In our project we have conducted various tests to verify whether our project fulfills it’s
objective.

At first in the login page we have tested the login facilities by providing wrong userid
,wrong password. The error message was flashed & login was denied .Then we tried to login by
leaving either one or two fields blank.Then again login was denied and error message was
flashed.After entering the correct user id and password users were redirected to their respective
home page.

After entering the Administrator module, we checked whether data was getting entered
in the database correctly. In the database there is referential integrity between the tables,so we
cannot delete a details without deleting the book. In the member section we tried to provide
invalid email ids but error message was flashed because validator has been used to validate email
ids. In the change password section we tested by entering wrong old password or retyping wrong
new password. In all cases error message was flashed.

In the member module also we checked for correct entry of data in database. In the
administrator nad member section,we tested the searching facilities. In these sections we also
provided wrong email ids & error was flashed.

In the transaction module, we tested the issued book for new issue purpose. This made
the error message flash. Then we also checked by issuing book to a blocked member. This also
caused error. We also tried to issue more number of book to a user whose bookcount was
limited. This also caused error.

In the member module, the password check and profile check are like the other modules.
Online Library Management System 88

SECURITY MEASURES TAKEN

It is necessary to enforce security measurements to prevent unauthorized users from


tampering the system or legal users from causing security problems due to callousness. The
following measurements are taken: -

1) LOGIN AND PASSWORD INFORMATION-


All the users have to pass through a User Id and Password checking process in
order to enter to the system.

2) PASSWORD ENCRYPTION-

The maximum length of the password should be 6 characters and it is encrypted using
―FTPasswordService‖ and ―encrypt‖ class, which has been made, by using ―regex‖ package
of java.

3) NO BACK-BUTTON LOGGING-

Once logged out, user cannot enter the system by using the back button of the browser.
So the user can leave the system safely.
Online Library Management System 89

Future Scope of the Project

Every project pertains to some future scopes and enhancements and based on these points
it is possible to progress further with the project. The followings are the future prospects:-

 If the mail server is made available in future we would further develop the system to
deliver the password to the mail id of the newly created user.
 The Secure Socket Layer (SSL) technology can be implemented.This technology will
ensure secure Internet communication between the Web Browser and Web Server..
 Depending on requirements by a member appropriate study material is to be given to
them.
 The teachers also can view the performance of any student of his department as well as of
other departments too.
 If due to any technical fault the access of any member is getting interrupted, he/she can
resume from the point of interruption.
 Faciliteis would be given to members so that they can read ebooks from the web library.
 We would use applet servlet communication to use images in the book catalog.

With this points applied on this application, the application will surely become professional,
market ready, highly efficient and effective for any organization.
Online Library Management System 90

Conclusion

This paper describes the complete implementation of a new Web-site. We first looked at an
overview of the needed technologies and processes which were required to develop such a
system. This included details of the framework utilized in the project and the features & behavior
of the framework. Next we looked at an in-depth analysis of the requirements to be developed
within the project and the design required in implementing these. A description of how the
system was developed followed with an analysis of the different interactions that occur in the
system. Finally a look at the results and a discussion were carried out to show what the current
system is capable of as well as what a future system could contain. Overall, we can see that by
interfacing with a web server online, users are able to have greater control over their account.

They are able to:

 Create Member User with proper User ID and system generated Password by the Admin
User.
 Admin hav the most control over the whole system to maintain security.
 Members can view transactions made by them and the fine over the grace period.
 All of the above Users can change password, edit profile etc.

With all the aforementioned benefits the Web Clients will find the system very useful and
appropriate.
Online Library Management System 91

BIBLIOGRAPHY

 www.w3schools.com/jsp/jsp_quiz.jsp (Quiz on JSP technology)

 http://www.sql-server-performance.com/articles_performance.asp (Quiz and


articles on SQL server)

 www.netbeans.org with it’s Docs&Supports & Other Features

 http://www.mysql.com (mysql)

 http://en.wikipedia.org/wiki/Apache_Tomcat ( acquire knowledge about


apache tomcat server)

 http://jakarta.apache.org/ (apache tomcat)

 http://msdn.microsoft.com/library/default.jsp?url=/library/en-
us/dnasp/html/asptutorial.jsp (JSP tutorial)

 www.sun.java.com (JAVA , JSP )

 www.springsource.org (spring)

 www.jQuery.com (jQuery)

Books :

Wrox Publications for JSP

Professional JAVA Server Programming by Allamaraju, Watson, Tyagi

& others (Apress Publication).

Head First Jsp & Servlets by Bryan Basham, Kathy Sierra, Bret Bates

You might also like