Professional Documents
Culture Documents
Online Library Management System Srs PDF Free
Online Library Management System Srs PDF Free
By
Bikramjit Banerjee
IN
Computer Science
Certificate
This is to certify that this thesis entitled‖Online Library Management System” is a bona-fide
record of work done by:
Bikramjit Banerjee
Assistant Professor
Of CSeT, Kolkata
PROF. A.S.CHODHURY
ACKNOWLEDGEMENT
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.
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
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.
Scope
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.
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
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.
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
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.
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
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
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.
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.
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
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
(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.
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
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
Web Server: ApacheTomcat (Apache Tomat is a powerful Web server that provides a highly reliable,
manageable, and scalable Web application infrastructure)
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.
DIAGRAMs:
DATA FLOW DIAGRAM(DFD)
Online Library Management System 17
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
Here
PROJECT DETAILS:
DATA DICTIONARY
BookMaster
Title This column Store the title of the book for the system
IsAvaliable This keeps the record of the book is available to user or not
Member
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
Transaction
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
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
Password This column stores the encrypted user password for the respective
users
type This column shows that if the user of the system is active or not
Online Library Management System 23
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;
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
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;
*/
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=?";
}
}
}
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
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);
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
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;
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;
}
}
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);
}
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
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
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
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
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();
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
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.Double getPrice()
java.lang.String getPublisher()
java.lang.String getSubject()
java.lang.String getTitle()
Constructor Detail
Book
public Book()
Method Detail
throws java.lang.Exception
Throws: java.lang.Exception
Throws: java.lang.Exception
Throws: java.lang.Exception
Class Member
java.lang.Object
onlinelibrary.beans.Member
Constructor Summary
Member()
Method Summary
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 getPassword()
java.lang.String getPin()
java.lang.String getRoad()
java.lang.String getWhyblocked()
boolean isBlocked()
boolean isSex()
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
Member
public Member()
Method Detail
throws java.lang.Exception
Throws: java.lang.Exception
java.lang.String doj)
throws java.lang.Exception
Throws: java.lang.Exception
throws java.lang.Exception
Throws: java.lang.Exception
throws java.lang.Exception
Throws: java.lang.Exception
Online Library Management System 79
throws java.lang.Exception
Throws: java.lang.Exception
java.sql.Connection conn)
throws java.lang.Exception
Throws: java.lang.Exception
throws java.lang.Exception
Throws: java.lang.Exception
throws java.lang.Exception
Throws: java.lang.Exception
throws java.lang.Exception
Throws: java.lang.Exception
Class Transaction
java.lang.Object
onlinelibrary.beans.Transaction
Constructor Summary
Transaction()
Method Summary
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()
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
Method Detail
Class UserMaster
java.lang.Object
onlinelibrary.beans.UserMaster
Constructor Summary
Constructor and Description
UserMaster()
Method Summary
Modifier and Type Method and Description
java.lang.String getPassword()
java.lang.Integer getType()
java.lang.String getUserid()
java.lang.String getUsername()
Constructor Detail
Method Detail
Class Hierarchy
java.lang.Object
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
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 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.
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
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
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.
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
http://www.mysql.com (mysql)
http://msdn.microsoft.com/library/default.jsp?url=/library/en-
us/dnasp/html/asptutorial.jsp (JSP tutorial)
www.springsource.org (spring)
www.jQuery.com (jQuery)
Books :
Head First Jsp & Servlets by Bryan Basham, Kathy Sierra, Bret Bates