You are on page 1of 15

Q. Explain Multi-Tier architecture.

Multi-tier architecture is a client-server architecture or


multi-layer architecture in which presentation,
application processing, and data management functions
are physically separated.
It provides a model by which developers can create
flexible and reusable applications. The application logic
is divided into various tires by their functionality : 

1 . User interface tire-


Handles the users interaction with the application. It
could be a web browser run through a firewall or a
desktop application and so on . 

2. Presentation Tier-
Define what the user interface displays and how we
request our handle.

3. Business tier-
This is where the brain of the application resides.  It
contains stuff such as business rules, business data
manipulation and so on. 

4. Infrastructure Services-
Provides additional functionality which are required by
the application components such as messaging,
transactional support and so on.

5. Integration / Data Access Tier-


This tire is responsible for providing access to relational
databases and other external systems. This layer is
where generic methods to interface with the data
storage are written.

6. Data Tier-
Data tier could be a DBMS such as MySQL, Oracle and
so on. This layer is indented to deal with the storage and
retrieval of data.

Q. Short note on Enterprise Architecture.


Java EE platform it’s designed to help developers create
large-scale,multi-tiered,scalable,reliable,network
application. A distributed, multi tired, application
model can be described add an enterprise application as
this application are designed to solve the problems
encountered by large enterprises.
It is an extension of the concept of multi tier
architecture and can run across hardware and software
frameworks found across an enterprise, often
spanning(#spread over)  geographical boundaries.
application logic is divided into components According
to functions and the various components together make
up the enterprise application. 
All components work together in harmony across the
enterprise-
1. Client Tier- Services run on the client machine
2. Web Tier-services run on the Java EE server
3. Business Tier- services run on the Java EE server
4. Enterprise information system(EIS) Tier- Software
runs on database server machine.
The Client Tier-
It consists of a client program that makes request to the
web tier.
A client can be-
1. A Web Client
OR
2. An Application Client

1. Web Client
It consists of-
a. Dynamic web page containing various types of
mark up language type html Which are generated
by web component running in the web tier . 
b. Web Browser which render the pages received
from the server . 
2.Application Client
It runs on a client machine and provides away for users
to handle the task which requires a richer user interface
which cannot be provided by a markup language.

Web Tier
It consists of some component which handles the
interaction between client and the business tier.
It performs following task
Collect input from client and collect appropriate
response.
The following technology use in web tier-
a. Servlets
b. JSP(Java Server Pages)
c. JSPL(Java Server Pages Standard Tag Library)
d. JSF(Java Server Faces)
e. Facelets
Business Tier
It consists of component which provide business logic
for an application. The business logic here is handled by
enterprise beans.
4. Enterprise Information System(EIS) Tier-
It consist of-
a. The database server for data storage
b. Enterprise Resource Planning System
c. Transaction processing
d. Other legacy systems
These resources typically are located on a separate
machine than the Java EE server and are accessed by
the components on business tier.
Calling technologies are used in EIS tire-
a. JDBC( Java Database Connectivity)
b. Java persistence API
c. Java EE
d. JTA ( Java Transaction API)
e. Java Connector Architecture

Q. What is servlet and write  short note on java


servlet technology.

Java Servlet Technology


1. Is a module written using Java that runs in a server
application to answer client requests.
2. Is most commonly used with HTTP and the word
Servlet is often used in the meaning of HTTP Servlet
3. Is supported by virtually all Web Servers and
Application Servers.
4. Can easily share resources.
5. Can be easily ported to other platforms that support
Java,as it runs inside JVM.
6. When user issues a request for a URL that corresponds
to a Java Servlet for processing.The servlet dynamically
produces a response to the requests, typically an HTML
Web page and sends it back to the requesting web
browser.
7. Are platform independent,they run using a set of
standard interfaces[that makeup servlet engine] and a
JVM.It is the JVM that is built to run on a specific
hardware platform.
8. Can access all of the Enterprise APIs such as
JNDI,JDBC,RMI and EJB and so on. 
9. Provides as a middle tier for web server based
applications.
Q. What is the request dispatcher interface and how
to obtain object implementing it?
Request dispatcher interface is used for dispatching a
request.
Request dispatcher defines an object which receives
request from a visitor’s browser and sends this request
to any other resource such as servlet, HTML file, or JSP
on the web server.
Obtaining an Object Implementing Request Dispatcher-
An Object Implementing Request Dispatcher Interface
may be obtained using the following methods-
 getRequestDispatcher()-
returns the object of request dispatcher for a given path.
Syntax- 
getRequestDispatcher(path);
There are two ways of using getRequestDispatcher()-
a. javax.servlet.ServletContext.getRequestDispatcher(
)
b. javax.servlet.ServletRequest.getRequestDispatcher(
)
a. ServletContext.getRequestDispatcher()
It takes string argument. The argument must describe an
absolute path within the scope of ServletContext. 
The absolute path described must be related to the root
directory of the web application and begin with a ‘/’.
b. ServletRequest.getRequestDispatcher()
to allow request dispatcher objects to be obtained using
relative to the path of the current request and not
relative to the root,
ServletRequest.getRequestDispatcher() is provided in
the ServletRequest interface.
 getNamedDispatcher()-
getNamedDispatcher is the convenience method that
accepts a name associated with the servlet.
Syntax- 
getNamedDispatcher(String <name>);
it text string argument which is the name of a servlet .
This is the same name that is specified –
a. Either in deployment descriptor file (web.xml)
b. Or in the annotated servlet under the name attribute
of @Web Servlet 

Q. Methods of request dispatcher interface.


Request dispatcher interface is used for dispatching a
request.
Request dispatcher defines an object which receives
request from a visitor’s browser and sends this request
to any other resource such as servlet, HTML file, or JSP
on the web server.
Request dispatcher interfaces 2 methods-
1. include()
2. forward()
Both the methods allow delegating the request response
processing to another resource, after calling Servlet has
finished any preliminary processing.
1. include()-
include( ) allows including the content produced by
another resource such as Sevlet, JSP or an HTML file in
the calling servlet's response.
Syntax-
public void include(ServletRequest request,
ServletResponse response)

include() method can be called anytime.

The request object passed to the target object will


reflect the request URL path as well as the path from
where the calling request originated.

The servlet target writes information to


ServletOutputStream or the writer of the response
object.

The ServletRequest object’s path elements and


parameters remain unchanged.

The included servlet cannot change the response header


on status code.

2. forward()-
forward() allows forwarding the request to another JSP
or HTML or servlet page on the server.

This resource takes over the responsibility for


producing the response.
Syntax-
public void forward(ServletRequest request,
ServletResponse response)
The resource takes over the responsibility of producing
the response.

Forward is useful when one servlet does some


preliminary processing Offer request and wants to let
another object complete the generation of the response.

Q.Write a short note on types of cookies.


The cookies are small text files created by a server side
program such as servlet that runs on the web server.
There are 2 types of cookies:
a. Permanent/ persistent cookies-
Permanent/ persistent cookies are those cookies
that are stored on a user's computer and are not
deleted when the browser is closed.
Permanent cookies can be used to identify
individual users, show that the website can analyse
the users surfing behaviour within the website.
Cookies can also be used to provide site
information such as the number of visitors, the
average time spent on a particular page and
generally the performance of the website.
They are usually configured to keep track of user
for prolonged period of time.
Session/Transient cookies-
Session of transient cookies are those cookies that
are stored in computers memory only during a
user's browsing session and are automatically
deleted from the users computer when the web
browser is closed.
This cookies usually story session ID that is not
permanently bound to the user, allowing the user to
move from page to page without having to login
repeatedly.
Session cookies are never written on the hard drive
and they do not collect any information from the
users computer.
Session cookies expire at the end of the users
browser session.
They also become no longer accessible after the
session has been inactive for a specific length of
time.

Q. Explain setting,sending and retrieving of cookies.


The cookies are small text files created by a server side
program such as servlet that runs on the web server.
Setting a cookies-
To set a cookie,call the cookie constructor by passing it
a cookie name and value, where name and values are
strings.
Cookie c= new Cookie(“username”, “TY”);
Servlet that wish to set cookies must add their cookie to
the response and back to the browser.

Sending a cookie-
Cookie is sent as headers of the response object to the
client.A cookie is added using response.addCookie()
Method of HttpServletResponse.

response.addCookie(c);

This method adds the specified cookie to the response


object. To store multiple values more than one cookie
can be used.

Retrieving a cookie-
To retrieve a specific cookie all the available cookies
need to be retried using getCookies()  method Of
HttpServlet.getCookie() Which returns an array of
objects.

This array can be search for a specific cookie.

Cookie [] cookie=request.getCookies();
The cookie name and value is extracted using
getName() and getValue() of The cookie object and
store in a variable.

Q. Write life cycle of HTTP session.


1. A visitor, using a browser, makes a request for a
resource from the web server.

2. The web server delivers the authentication module


that results in the visitor’s web browser displaying
a login form.

3. The visitor keys in a valid username and


password,which is then returned to the web server.

4. The webs server returns a valid SESSION ID that


follows this visitor to be uniquely identified.
(Session id is sent in a cookie that is returned by
the visitors browser with each request).This begins
the HTTP Session.

5. The visitor’s web server issues any number of


requests,the web server is able to identify the
visitor’s web browser base on the SESSION ID
that accompanies  each request.

6. The visitor closes the browser without logging out.

7. After thirty minutes,the web server expires the


session by deleting the SESSION ID. This
concludes the HTTP Session.

You might also like