1.servlets Introduction
1.servlets Introduction
nd
DURGASOFT, # 202,2 Floor,HUDA Maitrivanam,Ameerpet, Hyderabad - 500038, 040 – 64 51 27 86, 80 96
96 96 96, 9246212143 | www.durgasoft.com Page 1
JAVA MEANS DURGASOFT
Introduction
In general by using Java technology we are able to design following 2 types of
applications.
Java
1. Standalone Applications:
These are the java applications, which will be designed without using Client-Server
Architecture.
1. CUI Applications
2. GUI Applications
Q: What are the differences between CUI Applications and GUI Applications?
nd
DURGASOFT, # 202,2 Floor,HUDA Maitrivanam,Ameerpet, Hyderabad - 500038, 040 – 64 51 27 86, 80 96
96 96 96, 9246212143 | www.durgasoft.com Page 2
JAVA MEANS DURGASOFT
Ans: CUI Applications are the standalone applications, which will be designed in such a way
to take input and to provide output by using Command prompt, where Command prompt is
acting as user interface and it able to support character data. So that the java application
which will design on the basis of command prompt i.e. character user interface is called as
CUI application.
GUI Applications are the standalone applications, which will be designed in such a way to
take input and to provide output by using a collection of Graphic component, where the
collection of Graphic components is acting as an user interface and it able to support GUI
component so that the java application which will be design on the basis of Graphical user
interface is called as GUI Application.
2. Enterprise Applications:
These are the java applications, which will be designed on the basis of Client-Server
Architecture. There are 2 types of Enterprise applications.
1. Web Applications
2. Distributed Applications
Ans: 1. Web Application is the server side application, it will be designed without disturbing
its application logic over multiple number of JVM’s.
2. In general web applications will be designed by using a set of server side technologies
called as Web technologies like CGI, Servlets, JSP’s and so on.
nd
DURGASOFT, # 202,2 Floor,HUDA Maitrivanam,Ameerpet, Hyderabad - 500038, 040 – 64 51 27 86, 80 96
96 96 96, 9246212143 | www.durgasoft.com Page 3
JAVA MEANS DURGASOFT
3. The main purpose of web applications is to generate dynamic response from server
machine, but the main purpose of distributed applications is to establish distributed
communication between local machine and remote machine in order to access the remote
services.
4. In general web applications will provide services for web clients, but distributed
applications will provide services for any type of clients.
5. In general web applications will be executed by using both web servers and application
servers, but distributed applications will be executed by using only application servers.
1. Web Applications:
Web Application is a collection of web components, it will be executed by using web
containers like Servlet Container to execute servlets, Jsp Container to execute JSP’s and so
on.
2. Distributed Applications:
Distributed Application is a collection of distributed components, it will be executed by
using the distributed containers like EJB’s Container to execute EJB’s.
At the beginning stages of the computer we have Client-Server architecture, where the
purpose of server is to hold up some resources and to share that resources to all the clients
as per the client request.
In the above context, when we send a request from client to server for a particular
resource then server will identify requested resource, pick up the content and send that
content as response to client without performing any particular action at server. In this case
the response which was generated by server is called as static response.
nd
DURGASOFT, # 202,2 Floor,HUDA Maitrivanam,Ameerpet, Hyderabad - 500038, 040 – 64 51 27 86, 80 96
96 96 96, 9246212143 | www.durgasoft.com Page 4
JAVA MEANS DURGASOFT
As per the application requirements we need to generate dynamic response from server,
for this we need to execute the application at server called as Web Application. To design
web applications at server side we need a set of server side technologies called as Web
Technologies.
To design web applications we will use web technologies like CGI, Servlets, Jsp’s, Perl,
PHP and so on. Therefore, the main purpose of servlets and jsp’s is to design web
applications at server in order to generate dynamic response from server.
Ans: CGI is the server side technology designed on the basis of C technology and Scripting.
C technology is the process based technology, it will make CGI technology as process based
technology.
If we deploy any CGI application at server side then container will create a separate
process for each and every request. If we increase number of requests automatically CGI
container will generate number of processes at server.
Basically process is a heavy weight component, to handle single process system has to
consume a lot of system memory and execution time.
Due to the above reason to handle the multiple number of processes at a time server
machine may get burden, due to this reason server may generate delayed responses to the
client request, it will reduce the performance of server side application.
In the above context, to increase the performance of the server side application we have
to use an alternative server side technology i.e. Servlets.
P1
Client
nd
DURGASOFT, # 202,2 Floor,HUDA Maitrivanam,Ameerpet,
CGI Hyderabad - 500038, 040 – 64 51 27 86, 80 96
96 96 96, 9246212143 | www.durgasoft.com Page 5
JAVA MEANS DURGASOFT
req1
req2 P2
Client
reqn
Client
Pn
CGI Container
Server
Servlet is the server side technology designed on the basis of java technology. Java
technology is a Thread based technology, it will make servlets as Thread based
technologies.
If we deploy any servlet application at server then for every client request servlet container
will generate a separate thread on the respective servlet object.
In the above context, if we increase number of requests even container will create number
of threads instead of processes.
When compared to process thread is light weight, to handle multiple number of requests
i.e. thread server machine may not get burden, it may provide quick responses for the
client request, it may increase the performance of server side application.
t1 t2 ..... tn
nd
DURGASOFT, # 202,2 Floor,HUDA Maitrivanam,Ameerpet, Hyderabad - 500038, 040 – 64 51 27 86, 80 96
96 96 96, 9246212143 | www.durgasoft.com Page 6
JAVA MEANS DURGASOFT
req2
Client
Servlet object
reqn
Client
Servlet Container
Server
Ans: 1. If we want to design web applications by using Servlets we must require very good
java stuff.
To design web applications by using Jsp technology it is not required to have java
knowledge, it is sufficient to have presentation skills.
Note: The main intention to introduce Jsp technology is to reduce java code as much as
possible in web applications.
2. In web applications, we will prefer to use Servlets to pick up the request and process the
request.
But we will prefer to use Jsp’s to generate dynamic response to the client with very good
look and feel.
Note: In web applications, we will utilize Servlets to provide controller logic, integration
logic, validation logic, implementing business logic and so on. But we will prefer to use Jsp
technology only to provide presentation part.
3. In case of Servlets, we are unable to separate both presentation logic and business logic,
but in case of Jsp’s we are able to separate presentation logic and business logic because in
nd
DURGASOFT, # 202,2 Floor,HUDA Maitrivanam,Ameerpet, Hyderabad - 500038, 040 – 64 51 27 86, 80 96
96 96 96, 9246212143 | www.durgasoft.com Page 7
JAVA MEANS DURGASOFT
Jsp pages we are able to use html tags to prepare presentation logic and we are able to use
Jsp tags to prepare business logic.
If we perform any modifications on the existed Jsp’s then it is not required to perform
recompilation and reloading because Jsp pages are auto compiled and auto loaded.
5. If we want to design any web application on the basis of MVC architecture then we have
to use a servlet as controller and a set of Jsp pages as view part.
Model
request Servlet
JavaBeans
EJBs
Client
Jdbc
DB
response HBn
Jsps
Server
Note 1: Struts is a web application framework designed on the basis of MVC architecture,
where we have to use ActionServlet as controller and we have to use a set of Jsp pages as
view part.
Note 2: JSF(Java Server Faces) is a web application framework, where we have to use
FacesServlet as a controller and a set of Jsp pages as view part.
Enterprise:
Enterprise is a business organization, a group of organizations running under a single label.
nd
DURGASOFT, # 202,2 Floor,HUDA Maitrivanam,Ameerpet, Hyderabad - 500038, 040 – 64 51 27 86, 80 96
96 96 96, 9246212143 | www.durgasoft.com Page 8
JAVA MEANS DURGASOFT
Enterprise Application:
It is a software application, which will be designed for a particular enterprise in order to
simplify the internal business processing.
To prepare User Interface Layer in enterprise application we will use a separate logic is
called as Presentation Logic.
nd
DURGASOFT, # 202,2 Floor,HUDA Maitrivanam,Ameerpet, Hyderabad - 500038, 040 – 64 51 27 86, 80 96
96 96 96, 9246212143 | www.durgasoft.com Page 9
JAVA MEANS DURGASOFT
Business Processing Layer is the heart of the enterprise application, it will provide very
good environment to define and execute all the business rules and regulations which are
required by the client.
To prepare Business Processing Layer in enterprise application we will use a separate logic
is called as Business Logic.
The main purpose of this layer is to provide data persistency in enterprise application.
Data Storage and Access Layer will provide very good environment to provide the basic
database operations(CRUD) as per the enterprise application requirement.
To prepare Data Storage and Access Layer we will use a separate logic called as
Persistence Logic.
1-Tier Architecture
2-Tier Architecture
--------------------
nd
DURGASOFT, # 202,2 Floor,HUDA Maitrivanam,Ameerpet, Hyderabad - 500038, 040 – 64 51 27 86, 80 96
96 96 96, 9246212143 | www.durgasoft.com Page 10
JAVA MEANS DURGASOFT
n-Tier Architecture
1-Tier Architecture:
To design enterprise application if we use 1-tier architecture then we have to provide
User Interface Layer, Business Processing Layer and Data Storage and Access Layer within a
single machine.
1-Tier architecture will not provide any environment to handle multiple number requests,
it is able to provide less sharability.
U.I.L
B.P.L
DB
D.S.A.L
1-Tier Architecture
2-Tier Architecture:
To design any enterprise application it is minimum to use 2-Tier architecture. The best
example for 2-Tier architecture is Client-Server architecture.
2-Tier architecture will allow to design and execute the application in 2 layers of
machines.
nd
DURGASOFT, # 202,2 Floor,HUDA Maitrivanam,Ameerpet, Hyderabad - 500038, 040 – 64 51 27 86, 80 96
96 96 96, 9246212143 | www.durgasoft.com Page 11
JAVA MEANS DURGASOFT
In case of 2-Tier architecture, tier-1 will manage User Interface Layer and tier-2 will
manage Business Processing Layer and Data Storage and Access Layers.
2-Tier architecture will provide loosely coupled design when compared with 1-Tier
architecture.
2-Tier architecture will provide very good environment to handle multiple number of
requests and it is able to improve sharability.
B.P.L
U.I.L
DB
D.S.A.L
Client-Tier/Tier-1 Server-Tier/Tier-2
2-Tier Architecture
nd
DURGASOFT, # 202,2 Floor,HUDA Maitrivanam,Ameerpet, Hyderabad - 500038, 040 – 64 51 27 86, 80 96
96 96 96, 9246212143 | www.durgasoft.com Page 12
JAVA MEANS DURGASOFT
nd
DURGASOFT, # 202,2 Floor,HUDA Maitrivanam,Ameerpet, Hyderabad - 500038, 040 – 64 51 27 86, 80 96
96 96 96, 9246212143 | www.durgasoft.com Page 13