You are on page 1of 41

Online Blood Bank System using Android App 2018











Dept of CS, KFGSC, Tiptur Page 1

Online Blood Bank System using Android App 2018


We express our grateful acknowledgement to our institution


us an opportunity to fulfill our cherishing ambition of becoming Junior

Engineers in computer science.

We have great pleasure in expressing our deep sense of gratitude to

our Principal PROF Dr. S. BASAVA RADDI, KFGSC, Tiptur for having

provided all the facilities to work out this project.

We are grateful to our Head of the department, CSE, Mr. VINAY.M.S

for his unfailing encouragement, invaluable guidance and suggestion given
to us in the course of our project work.

We are also thankful to all the Lecturers who have helped us

throughout this project with their invaluable guidance.

We are extremely thankful to various Departments for providing us

Data and also to our college and the Entire staff.

Last, but certainly not the least we thank all our friends who have
been very helpful throughout the project with their invaluable suggestions
at time to time, and also like to thank all the teaching and non-teaching
staff, for their kind co-operation.

Dept of CS, KFGSC, Tiptur Page 2

Online Blood Bank System using Android App 2018

The main aim of developing this system is to provide blood to the
people who are in need of blood. The numbers of persons who are in need of
blood are increasing in large number day by day. Using this system user
can search blood group available in the city and he can also get contact
number of the donor who has the same blood group he needs. In order to
help people who are in need of blood, this Online Blood Bank management
system can be used effectively for getting the details of available blood
groups and user can also get contact number of the blood donors having the
same blood group and within the same city.

So if the blood group is not available in the blood bank user can
request the donor to donate the blood to him and save someone life. Using
this bank management system people can register himself or herself who
want to donate blood. To register in the system they have to enter their
contact information like address mobile number etc.

This blood bank management system is an online website so it is

easily available to everyone. When a person want to donate blood he have to
register to the system.

Donor registration is very easy, to get register to the system he have to

fill up registration form. After submitting the registration form he can create
username and password. Donor have to give information like blood group,
contact details etc.

Donor can also change his account information when he wants using
his username and password.

Using this blood bank system people can search blood group available
which they are needed. They check it online using our blood bank
management website. If in case blood group is not available in blood bank
they can also get contact numbers of the persons who has the same blood
group he is need. And he can request the person to donate the blood for
saving someone life. Our system also allow user to search online the person
who have the same blood group he needs and if he find the If he find a
donor in his city then we give him all details of the donor, if he doesn’t find
any donor then he is given the contact numbers and addresses of the Life
Saving Contact Persons for big cities.

Dept of CS, KFGSC, Tiptur Page 3

Online Blood Bank System using Android App 2018


The blood is specialized bodily fluid that delivers necessary

substances to the body’s cells such as nutrients and oxygen. Blood banking
is a cache or bank of blood or blood components, gathered as a result of
blood donation, stored and preserved for later use in blood transfusions. In
addition to this, the blood type of patients also needs to be determined for
compatibility sake for a blood transfusion. It is possible in some situations
that the patient is unable to get the required amount of blood at right time
due to lack of interrelationship in form of a networked database among the
blood banks which leads to the lack of knowledge of updated record of all
blood donors. Today mobile and mobile based applications have become a
part of our day to day life. With the revolution in mobile computing many
great features were added to the field and the mobiles got smaller, faster
and better as the decade passed. This Android application is developed to
easily search for blood in nearby areas for emergency. In this Android app
one will get clear access to blood in real time and right place.

1.1 Motivation

The number of persons who are in need of blood are increasing in

large number day by day. In order to help people who are in need of blood,
my Online Blood Bank can be used effectively for getting the details of blood
donors having the same blood group and within the same city. With the help
of my Online Blood Bank people who are having the thought of donating
blood gets registered in my Online Blood Bank giving his total details.

Dept of CS, KFGSC, Tiptur Page 4

Online Blood Bank System using Android App 2018

My Online Blood Bank site is available to everyone easily. A person

who likes to donate blood gives his entire details i.e., fill in the registration
form and can create a username with a password by which he can modify
his details if at all there are any changes in his information given before.

1.2 Scope

My site also helps people who are in need of blood by giving the
details of the donors by searching, if at all there are no donors having the
same group and with in their own city they will be given the addresses with
phone numbers of some contact persons in major cities who represent a
club or an organization with free of cost. If at all the people find any
difficulty in getting blood from the contact persons we will give them a
MobiLink i.e., India’s Largest Paging Service number through which they
can give the message on every ones pagers with the blood group and city
they are living in, such that the donors who view the messages in their
pagers having the same blood group and the in the same city, he contacts
the person on phone who are in need of a blood. Such that the person gets
help from us which saves his life.

The present project elucidates the following features.

 Registering the Donors

 Modification of Donor Information

 Searching a Donor

 Life Saving Contacts (in major cities)

methods for developing systems is widely recognized to be effective

and the applied model should meet a few basic requirements.

 The model should be structured and cover the entire system

development process from feasibility study to programming,
testing and implementation.

Dept of CS, KFGSC, Tiptur Page 5

Online Blood Bank System using Android App 2018

 The model should utilize established methods and techniques

like database designs, normalizations and structured
programming techniques.

 The model should consist of building blocks, which define

tasks, results and interfaces.

 The model should separate the logical system from the physical

 Documentation should be a direct result of the development

work and should be concise, precise and as non-redundant as

Based on the above requirements of the system model, system study has

been made. Various methodologies have been applied for system study,

evolving design documents, data modeling, input screen design and report


1.3 Problem Statement

The persons who like to donate blood registers in my site as well as he

can modify the details if necessary, giving the Login Id and Password. The

persons in need of blood searches for the persons having the same blood

group and within the city. If he found a donor in his city then he gets the

total details of the donor, if he doesn’t find any donor then he is given the

contact numbers and addresses of the Life Saving Contact Persons for major

cities. If he doesn’t have any chance to contact them then he will be

provided with Mobilink Paging Services in order to get the blood.

Dept of CS, KFGSC, Tiptur Page 6

Online Blood Bank System using Android App 2018

1.4 Existing System

In existing Blood Bank Project system, if someone needs the blood,
then either the person have to go to the blood bank nearby to him or else
have to buy the blood from the hospital but in case, if both the places don’t
have the blood of the required group than finding blood of that group might
be a tough task at the required time.
In existing Blood Bank Project system, wastage of time is done more
and still there will be chances that you won’t get blood at the required time.

1.5 Proposed System

The proposed Blood Bank Project system will help the needy person,
access to all the donors of the blood of the particular group, nearby to their
place, in a minutes of time. The details will include the name of the donor,
his/her blood group, contact number and address.
This automated Blood Bank Project will reduce the time and efforts for
finding the right choice of donor for the needy receiver and thus most of the
times helps the person to save his/her life also.

1.6 The advantages of the proposed system

The people in need of blood can search for the donors by giving their
blood group and city name. it saves time as he can search donors online
without going anywhere. Using this system user can get blood in time and
can save his relative or friend life. Our website work 24x7 so user can get
information of blood donor any time. Blood donor can also get registered
and save life of other person. The main benefit of this system is the
information of available blood group. When blood is need in the operation
then people have very less time to get the blood available so if he get the
information like who can give him blood in time in his city is life saving. And
here our system work, whenever a person need blood he get information of
the person who has the same blood group he needs.

Dept of CS, KFGSC, Tiptur Page 7

Online Blood Bank System using Android App 2018

Chapter 2
A blood bank is a center where blood gathered as a result of blood
donation is stored and preserved for later use in blood transfusion. The
term "blood bank" typically refers to a division of a hospital where the
storage of blood product occurs and where proper testing is performed (to
reduce the risk of transfusion related adverse events). However, it
sometimes refers to a collection center, and indeed some hospitals also
perform collection.

Routine blood storage is 42 days or 6 weeks for stored packed red

blood cells (also called "StRBC" or "pRBC"), by far the most commonly
transfused blood product, and involves refrigeration but usually not
freezing. There has been increasing controversy about whether a given
product unit's age is a factor in transfusion efficacy, specifically on whether
"older" blood directly or indirectly increases risks of complications. Studies
have not been consistent on answering this question, with some showing
that older blood is indeed less effective but with others showing no such
difference; nevertheless, as storage time remains the only available way to
estimate quality status or loss, a first-in-first-out inventory management
approach is standard presently. It is also important to consider that there is
large variability in storage results for different donors, which combined with
limited available quality testing, poses challenges to clinicians and
regulators seeking reliable indicators of quality for blood products and
storage systems.

Transfusions of platelets are comparatively far less numerous, but

they present unique storage/management issues. Platelets may only be
stored for 7 days, due largely to their greater potential for contamination,
which is in turn due largely to a higher storage temperature.

Dept of CS, KFGSC, Tiptur Page 8

Online Blood Bank System using Android App 2018

The basic building aim is to provide blood donation service to the city
Blood Bank Management System (BBMS) is a Web based application that is
designed to store, process, retrieve and analyze information concerned with
the administrative and inventory management within a blood bank.

This project aims at maintaining all the information pertaining to

blood donors, different blood groups available in each blood bank and help
them manage in a better way.

Project Aim is to provide transparency in this field, make the process of

obtaining blood from a blood bank hassle free and corruption free and make
the system of blood bank management effective.

Blood bank is a place where blood bag that is collected from blood
donation events is stored in one place. The term “blood bank” refers to a
division of a hospital laboratory where the storage of blood product occurs
and where proper testing is performed to reduce the risk of transfusion
related events (Vikas Kulshreshtha, Sharad Maheshwari). Pathology
Department is one of the most important departments in Sultanah Nur
Zahirah Hospital (HSNZ). It processes blood that will be supplied to the
patients in HSNZ according to their needs. Before the blood is supplied to
the patients, the blood will undergo several tests to ensure that the blood
receiver is not infected by serious diseases. There are a few units operating
in this department such as Blood House Unit, Blood Transfusion Unit, and
Blood Distribution Unit. Every month, HSNZ will organize blood donation
event which is one of the way they can increase the blood stock. After the
blood donation events, the blood bags that they obtained will undergo tests.

All of the blood received at the blood donation events must be

managed thoroughly and systematically to avoid patient who need the blood
infected by any viruses or diseases. Blood Bank Management System
(BBMS) is a web based system that can assists the information of blood bag
Dept of CS, KFGSC, Tiptur Page 9
Online Blood Bank System using Android App 2018

during its handling in the blood bank. With this system, the user of this
system can key in the result of blood test that has been conducted to each
of the blood bag received by the blood bank. The result of test will indicate
whether the blood bag can be delivered to patient or not. From this system,
there are several type of report that can be generated such as blood stock
report, donor’s gender report and the total of blood donation according to
months and year. The system also can give the information to the donor
about blood analysis test result for each time the donor makes contribution.
Hence, BBMS will make the blood bank stock more systematic and

In “The Optimization of Blood Donor Information and Management

System by Technopedia” by P. Priya and V.Saranya have proposed an
efficient and reliable blooddonor information and management system based
on GIS integrated in android mobile application. The service provided by the
proposed system is needed and valuable to health sector where a quality of
the blood is considered for the safety of the patient through a systematic
process by the blood management system. This system will be the solution
for the problems such as wrong information of donors, misuse by third
parties and updating the donated blood by the donor which replaces the
older systems. The proposed system is a web based android application
helps us to reduce the human mistakes which are done in the existing

The wireless internet technique enables the flow of data to work more
rapidly and conveniently. This is integrated framework which has a cloud-
based application on mobile devices. The future work of the system is to
extend this application to process through SMS services. By this the contact
is hidden from other members. Some other text or number will be generated
on behalf of the original phone number or email. This can be done without
using the internet service where the acceptor sends blood request to donor

Dept of CS, KFGSC, Tiptur Page 10

Online Blood Bank System using Android App 2018

by web but whereas the donor receiving the request is just a simple SMS in
mobile. By this there will be secure BTS where strangers can’t misuse the
details of donors and where strangers can become helping hand for life at
emergency situation.

In “MBB: A Life Saving Application” by Narendra Gupta, Ramakant

Gawande and Nikhil thengadi have proposed the system that will link all
donors. The system will help control a blood transfusion service and create
a database to hold data on stocks of blood in each area as data on donors in
each city. Furthermore, people will be able to see which patients need blood
supplies via the application. They will be able to register as donors and
thus receive request from their local clients who needs blood to donate blood
in cases of need. In “an android application for volunteer blood donors” by
Sultan Turhan [3] a smart phone’s application for the volunteer blood donor
to increase the willingness and accessibility with the purpose of providing a
continuous blood supply is presented.

This application helps health care centers to provide the blood as

quick as possible when their stocks are insufficient. The application sends
periodically actual location information of available donors to main system
and the blood requests to the donors. In this way, it provides an
uninterrupted communication between the health care centers and
volunteer donors. The distance of the volunteer donors to the healthcare
center is an important criterion in the determination of the donors.
Therefore an optimization is also realized on this process. In the initial
system, the distance calculation is made by taking the distance as crow
flies. In the optimized system, it is converted to the actual distance. This
optimization makes the system more realistic. The second improvement is
performed on the system’s infrastructure. Especially, by taking into
consideration the rapid development of mobile device technology which uses
Android operating system, the system has been carried from the from ANT

Dept of CS, KFGSC, Tiptur Page 11

Online Blood Bank System using Android App 2018

building environment onto Grade build automation platform. In further

studies, we aim the add evaluation of traffic density between living donors’
locations and healthcare centers to the living donor selection criteria.

Figure 2.1:Block diagram of Blood Bank system.

The user has to first download the application. He/She will be

provided with two options: Login and sign in. If the person has already
registered, then he/she has to login. If not, he/she has to create an account
providing basic details like name, address, contact, date of birth, blood
group, email id etc. The user is allowed to update his/her information. Once
the user registers, he/she can check various blood banks that are located.
The user will get various options on screen:


Dept of CS, KFGSC, Tiptur Page 12

Online Blood Bank System using Android App 2018

The user can select any of the option and according to the selected
option he/she will get the information. The user can also get the exact path
from his/her location to blood

bank or hospital by using Global Positioning System (GPS). The details of

the blood banks, hospitals etc will be saved in database and only the admin
will have access to database. Private and confidential data of the users can
only be viewed by administrator. This system promises very less paperwork
and also provides help to blood recipient, blood banks and donors also. With
help of our application the user will not have to go to the blood bank and
ask for the required blood he/ she can directly check from our application.

2.1 What is web application?

A web application is an application accessible from the web. A web

application is composed of web components like Servlet, JSP, Filter etc. and
other components such as HTML. The web components typically execute in
Web Server and respond to HTTP request.

2.1.1 CGI(Common Gateway Interface)

CGI technology enables the web server to call an external program

and pass HTTP request information to the external program to process the
request. For each request, it starts a new process.

Dept of CS, KFGSC, Tiptur Page 13

Online Blood Bank System using Android App 2018

Figure2.1: A Common Gateway Interface

2.1.2 What Is a Servlet?

A servlet is a Java programming language class used to extend the

capabilities of servers that host applications accessed by means of a
request-response programming model. Although servlets can respond to any
type of request, they are commonly used to extend the applications hosted
by web servers. For such applications, Java Servlet technology defines
HTTP-specific servlet classes.

The javax.servlet and javax.servlet.http packages provide interfaces

and classes for writing servlets. All servlets must implement
the Servlet interface, which defines lifecycle methods. When implementing a
generic service, you can use or extend the GenericServlet class provided
with the Java Servlet API. The HttpServlet class provides methods, such
as doGet and doPost, for handling HTTP-specific services.

Servlet technology is used to create web application (resides at server side

and generates dynamic web page).

Dept of CS, KFGSC, Tiptur Page 14

Online Blood Bank System using Android App 2018

Servlet technology is robust and scalable because of java language. Before

Servlet, CGI (Common Gateway Interface) scripting language was popular as
a server-side programming language. But there was many disadvantages of
this technology. We have discussed these disadvantages below.

Figure 2.3: A Java Servlet context.

Servlet can be described in many ways, depending on the context.

o Servlet is a technology i.e. used to create web application.

o Servlet is an API that provides many interfaces and classes including


o Servlet is an interface that must be implemented for creating any


o Servlet is a class that extend the capabilities of the servers and

respond to the incoming request. It can respond to any type of

o Servlet is a web component that is deployed on the server to create

dynamic web page.

Dept of CS, KFGSC, Tiptur Page 15

Online Blood Bank System using Android App 2018

There are many advantages of servlet over CGI. The web container creates
threads for handling the multiple requests to the servlet. Threads have a lot
of benefits over the Processes such as they share a common memory area,
lightweight, cost of communication between the threads are low. The basic
benefits of servlet are as follows:

1. better performance: because it creates a thread for each request not


2. Portability: because it uses java language.

3. Robust: Servlets are managed by JVM so we don't need to worry

about memory leak, garbage collection etc.

4. Secure: because it uses java language..

2.1.3 Servlet Lifecycle

The lifecycle of a servlet is controlled by the container in which the servlet

has been deployed. When a request is mapped to a servlet, the container
performs the following steps.

1. If an instance of the servlet does not exist, the web container

a. Loads the servlet class.
b. Creates an instance of the servlet class.
c. Initializes the servlet instance by calling the init method. Initialization
is covered in Creating and Initializing a Servlet.
2. Invokes the service method, passing request and response objects.
Service methods are discussed in Writing Service Methods.

If it needs to remove the servlet, the container finalizes the servlet by calling
the servlet’s destroymethod.

Dept of CS, KFGSC, Tiptur Page 16

Online Blood Bank System using Android App 2018

2.2 Website

Website is a collection of related web pages that may contain text,

images, audio and video. The first page of a website is called home page.
Each website has specific internet address (URL) that you need to enter in
your browser to access a website.

Website is hosted on one or more servers and can be accessed by

visiting its homepage using a computer network. A website is managed by
its owner that can be an individual, company or an organization.

2.2.1 Static website

Static website is the basic type of website that is easy to create. You don't
need web programming and database design to create a static website. Its
web pages are coded in HTML.

The codes are fixed for each page so the information contained in the page
does not change and it looks like a printed page.

2.2.2 Dynamic website

Dynamic website is a collection of dynamic web pages whose content

changes dynamically. It accesses content from a database or Content
Management System (CMS). Therefore, when you alter or update the content
of the database, the content of the website is also altered or updated.

Dynamic website uses client-side scripting or server-side scripting, or both

to generate dynamic content.

Client side scripting generates content at the client computer on the basis of
user input. The web browser downloads the web page from the server and
processes the code within the page to render information to the user.

Dept of CS, KFGSC, Tiptur Page 17

Online Blood Bank System using Android App 2018

In server side scripting, the software runs on the server and processing is
completed in the server then plain pages are sent to the user.

2.2.3 HTTP (Hyper Text Transfer Protocol)

The Hypertext Transfer Protocol (HTTP) is application-level protocol for

collaborative, distributed, hypermedia information systems. It is the data
communication protocol used to establish communication between client
and server.

HTTP is TCP/IP based communication protocol, which is used to deliver the

data like image files, query results, HTML files etc on the World Wide Web
(WWW) with the default port is TCP 80. It provides the standardized way for
computers to communicate with each other.

The Basic Characteristics of HTTP (Hyper Text Transfer Protocol):

o It is the protocol that allows web servers and browsers to exchange

data over the web.

o It is a request response protocol.

o It uses the reliable TCP connections by default on TCP port 80.

o It is stateless means each request is considered as the new request. In

other words, server doesn't recognize the user by default.

Dept of CS, KFGSC, Tiptur Page 18

Online Blood Bank System using Android App 2018

The Basic Features of HTTP (Hyper Text Transfer Protocol):

There are three fundamental features that make the HTTP a simple and
powerful protocol used for communication:

o HTTP is media independent: It refers to any type of media content

can be sent by HTTP as long as both the server and the client can
handle the data content.

o HTTP is connectionless: It is a connectionless approach in which

HTTP client i.e., a browser initiates the HTTP request and after the
request is sends the client disconnects from server and waits for the

o HTTP is stateless: The client and server are aware of each other
during a current request only. Afterwards, both of them forget each
other. Due to the stateless nature of protocol, neither the client nor
the server can retain the information about different request across
the web pages.

The Basic Architecture of HTTP (Hyper Text Transfer Protocol):

The below diagram represents the basic architecture of web application and
depicts where HTTP stands:

Dept of CS, KFGSC, Tiptur Page 19

Online Blood Bank System using Android App 2018

HTTP is request/response protocol which is based on client/server based

architecture. In this web browser, search engines, etc behaves as a HTTP
clients, and the Web server like Servlet behaves as a server.

2.3 HTML5 and Java Script

HTML5 is the latest and most enhanced version of HTML. Technically, HTML
is not a programming language, but rather a markup language.

Dept of CS, KFGSC, Tiptur Page 20

Online Blood Bank System using Android App 2018

Chapter 3

Blood Bank Android Project Modules

Given are the modules for the Android Blood Bank.
 Admin Module: In this module, the administration work is done such as
insertion and updation of new details, deletion of old details and so on.
 User Module: In this module, users use to do their task such as
registering themselves as an account member, getting details by filtering
of their own choices,
 Database Module: Here, in this module, all the database is maintained
and queries are being executed. Every database has its own table which
contains rows and tuple and every relation is being handles using SQL
queries, given either by user in the form of statement or else by admin.
 Content Module: In this module, some basic content will be share after
each time limit, for regular updation regarding blood disease and its
curing periods.
Technologies Used
 Java
 Android
 My SQL Server
Software Requirements
 Android software development kit (SDK)
 Windows 7
 Java Development Kit (JDK)
 Notepad
 Android debug bridge
Hardware Requirements
 Hard Disk – 2 GB.
 RAM – 1 GB.

Dept of CS, KFGSC, Tiptur Page 21

Online Blood Bank System using Android App 2018

 Processor – Dual Core or Above.

 Mouse.
 Keyboard.
 Monitor.
 Printer.

3.1 Data - Flow Diagrams Blood bank management system

Dept of CS, KFGSC, Tiptur Page 22

Online Blood Bank System using Android App 2018

3.2 Context Level DFD

3.3 Level 1 DFD

Dept of CS, KFGSC, Tiptur Page 23

Online Blood Bank System using Android App 2018

3.4 Writing Service Methods

The service provided by a servlet is implemented in
the service method of a GenericServlet, in the doMethod methods
(where Method can take the value Get, Delete, Options, Post, Put, or Trace)
of an HttpServlet object, or in any other protocol-specific methods defined
by a class that implements the Servlet interface. The term service method is
used for any method in a servlet class that provides a service to a client.

The general pattern for a service method is to extract information from the
request, access external resources, and then populate the response, based
on that information. For HTTP servlets, the correct procedure for populating
the response is to do the following:

1. Retrieve an output stream from the response.

2. Fill in the response headers.
3. Write any body content to the output stream.

Response headers must always be set before the response has been
committed. The web container will ignore any attempt to set or add headers
after the response has been committed. The next two sections describe how
to get information from requests and generate responses.

3.4.1Getting Information from Requests

A request contains data passed between a client and the servlet. All
requests implement the ServletRequest interface. This interface defines
methods for accessing the following information:

 Parameters, which are typically used to convey information between

clients and servlets
 Object-valued attributes, which are typically used to pass information
between the web container and a servlet or between collaborating

Dept of CS, KFGSC, Tiptur Page 24

Online Blood Bank System using Android App 2018

 Information about the protocol used to communicate the request and

about the client and server involved in the request
 Information relevant to localization

Figure 3.4: Transition Model for Blood Bank system.

Dept of CS, KFGSC, Tiptur Page 25

Online Blood Bank System using Android App 2018

Chapter 4


4.1 Servlet Construction

Retrieve an input stream from the request and manually parse the
data. To read character data, use the BufferedReader object returned by the
request’s getReader method. To read binary data, use
the ServletInputStream returned by getInputStream.

HTTP servlets are passed an HTTP request object, HttpServletRequest,

which contains the request URL, HTTP headers, query string, and so on. An
HTTP request URL contains the following parts:


The request path is further composed of the following elements:

 Context path: A concatenation of a forward slash (/) with the context

root of the servlet’s web application.
 Servlet path: The path section that corresponds to the component alias
that activated this request. This path starts with a forward slash (/).
 Path info: The part of the request path that is not part of the context
path or the servlet path.

The getContextPath, getServletPath and getPathInfo methods of

the HttpServletRequest interface to access this information. Except for URL
encoding differences between the request URI and the path parts, the
request URI is always comprised of the context path plus the servlet path
plus the path info.

Dept of CS, KFGSC, Tiptur Page 26

Online Blood Bank System using Android App 2018

Query strings are composed of a set of parameters and values. Individual

parameters are retrieved from a request by using the getParameter method.
There are two ways to generate query strings.

 A query string can explicitly appear in a web page.

 A query string is appended to a URL when a form with a GET HTTP
method is submitted.

4.2 Constructing Responses

A response contains data passed between a server and the client. All
responses implement the ServletResponse interface. This interface defines
methods that allow you to

 Retrieve an output stream to use to send data to the client. To send

character data, use the PrintWriter returned by the
response’s getWriter method. To send binary data in a Multipurpose
Internet Mail Extensions (MIME) body response, use
the ServletOutputStreamreturned by getOutputStream. To mix binary
and text data, as in a multipart response, use
a ServletOutputStream and manage the character sections manually.
 Indicate the content type (for example, text/html) being returned by the
response with the setContentType(String) method. This method must be
called before the response is committed. A registry of content type names
is kept by the Internet Assigned Numbers Authority (IANA)
 Indicate whether to buffer output with the setBufferSize(int) method. By
default, any content written to the output stream is immediately sent to
the client. Buffering allows content to be written before anything is sent
back to the client, thus providing the servlet with more time to set
appropriate status codes and headers or forward to another web

Dept of CS, KFGSC, Tiptur Page 27

Online Blood Bank System using Android App 2018

resource. The method must be called before any content is written or

before the response is committed.
 Set localization information, such as locale and character encoding.
See Chapter 17, Internationalizing and Localizing Web Applications for

HTTP response objects, javax.servlet.http.HttpServletResponse, have fields

representing HTTP headers, such as the following:

 Status codes, which are used to indicate the reason a request is not
satisfied or that a request has been redirected.
 Cookies, which are used to store application-specific information at the
client. Sometimes, cookies are used to maintain an identifier for tracking
a user’s session

4.3 Creating and Initializing a Servlet

Use the @WebServlet annotation to define a servlet component in a

web application. This annotation is specified on a class and contains
metadata about the servlet being declared. The annotated servlet must
specify at least one URL pattern. This is done by using
the urlPatterns or value attribute on the annotation. All other attributes are
optional, with default settings. Use the value attribute when the only
attribute on the annotation is the URL pattern; otherwise use
the urlPatterns attribute when other attributes are also used.

Classes annotated with @WebServlet must extend

the javax.servlet.http.HttpServletclass. For example, the following code
snippet defines a servlet with the URL pattern /report:

import javax.servlet.annotation.WebServlet;

Dept of CS, KFGSC, Tiptur Page 28

Online Blood Bank System using Android App 2018

import javax.servlet.http.HttpServlet;

public class LoginServlet extends HttpServlet {

The web container initializes a servlet after loading and instantiating

the servlet class and before delivering requests from clients. To customize
this process to allow the servlet to read persistent configuration data,
initialize resources, and perform any other one-time activities, you can
either override the init method of the Servlet interface or specify
the initParams attribute of the @WebServlet annotation.
The initParams attribute contains a @WebInitParam annotation. If it cannot
complete its initialization process, a servlet throws an UnavailableException.

Use an initialization parameter to provide data needed by a particular

servlet. By contrast, a context parameter provides data that is available to
all components of a web application.

4.4 Invoking Other Web Resources

Web components can invoke other web resources both indirectly and
directly. A web component indirectly invokes another web resource by
embedding a URL that points to another web component in content
returned to a client. While it is executing, a web component directly invokes
another resource by either including the content of another resource or
forwarding a request to another resource.

To invoke a resource available on the server that is running a web

component, you must first obtain a RequestDispatcher object by using
the getRequestDispatcher("URL") method. You can get
a RequestDispatcher object from either a request or the web context;
however, the two methods have slightly different behavior. The method

Dept of CS, KFGSC, Tiptur Page 29

Online Blood Bank System using Android App 2018

takes the path to the requested resource as an argument. A request can

take a relative path (that is, one that does not begin with a /), but the web
context requires an absolute path. If the resource is not available or if the
server has not implemented a RequestDispatcher object for that type of
resource, getRequestDispatcher will return null. Your servlet should be
prepared to deal with this condition.

Including Other Resources in the Response

It is often useful to include another web resource, such as banner content
or copyright information) in the response returned from a web component.
To include another resource, invoke the includemethod of
a RequestDispatcher object:

include(request, response);

If the resource is static, the include method enables programmatic server-

side includes. If the resource is a web component, the effect of the method is
to send the request to the included web component, execute the web
component, and then include the result of the execution in the response
from the containing servlet. An included web component has access to the
request object but is limited in what it can do with the response object.

 It can write to the body of the response and commit a response.

 It cannot set headers or call any method, such as setCookie, that affects
the headers of the response.

Transferring Control to Another Web Component

In some applications, you might want to have one web component do
preliminary processing of a request and have another component generate
the response. For example, you might want to partially process a request
and then transfer to another component, depending on the nature of the

Dept of CS, KFGSC, Tiptur Page 30

Online Blood Bank System using Android App 2018

To transfer control to another web component, you invoke

the forward method of a RequestDispatcher. When a request is forwarded,
the request URL is set to the path of the forwarded page. The original URI
and its constituent parts are saved as request
attributes javax.servlet.forward.[request-uri|context-path|servlet-

The forward method should be used to give another resource responsibility

for replying to the user. If you have already accessed
a ServletOutputStream or PrintWriter object within the servlet, you cannot
use this method; doing so throws an IllegalStateException.

4.5 Finalizing a Servlet

The web container may determine that a servlet should be removed
from service (for example, when a container wants to reclaim memory
resources or when it is being shut down). In such a case, the container calls
the destroy method of the Servlet interface. In this method, you release any
resources the servlet is using and save any persistent state.
The destroy method releases the database object created in the init method .

A servlet’s service methods should all be complete when a servlet is

removed. The server tries to ensure this by calling the destroy method only
after all service requests have returned or after a server-specific grace
period, whichever comes first. If your servlet has operations that may run
longer than the server’s grace period, the operations could still be running
when destroy is called. You must make sure that any threads still handling
client requests complete.

Dept of CS, KFGSC, Tiptur Page 31

Online Blood Bank System using Android App 2018

Chapter 5

Dept of CS, KFGSC, Tiptur Page 32

Online Blood Bank System using Android App 2018

Dept of CS, KFGSC, Tiptur Page 33

Online Blood Bank System using Android App 2018

Dept of CS, KFGSC, Tiptur Page 34

Online Blood Bank System using Android App 2018

Dept of CS, KFGSC, Tiptur Page 35

Online Blood Bank System using Android App 2018

Dept of CS, KFGSC, Tiptur Page 36

Online Blood Bank System using Android App 2018

Dept of CS, KFGSC, Tiptur Page 37

Online Blood Bank System using Android App 2018

Dept of CS, KFGSC, Tiptur Page 38

Online Blood Bank System using Android App 2018

Dept of CS, KFGSC, Tiptur Page 39

Online Blood Bank System using Android App 2018

Chapter 6

Our project is only a humble venture to satisfy the needs to manage

the people who are in search of blood at emergency. The complete work is to
build the online database of people and to show the information to those
people who are in need of the blood. Several user friendly coding is adopted.
The system proves and provide the initial stage for the development of
complete blood bank system where the various hospitals and other agencies
can utilize the system for the interconnection with their modules. This
project work has many future developments showing the instant mailing,
SMS service and other which makes the network of people to know the
emergence in faster sense.
The project is the base model for many other architectures. The work
is carried out using the java servlet and tomcat environment.

Dept of CS, KFGSC, Tiptur Page 40

Online Blood Bank System using Android App 2018


1. William Crawford, Jason Hunter , "Java Servlet Programming, 2nd

Edition", Help for Server Side Java Developers , O'Reilly Media, 2010.
2. John Paul Mueller, HTML5 Programming with JavaScript For
Dummies, ISBN:1118431669 9781118431665, The ACM Digital
Library is published by the Association for Computing Machinery,
3. Oracle Java Libraries,
4. Wikipedia for Blood Bank system and Java servlet development.

Dept of CS, KFGSC, Tiptur Page 41