EJ Question Bank
EJ Question Bank
UNIT 1
1. Explain the architecture of Java Enterprise Application. (Nov
2019)
Ans)
System architecture has four different types of architecture.
Single Tier architecture:
The User interface of a web application i.e. The Presentation layer.
• The middleware i.e. The business rules.
• The data access layer are all contained in one single computer.
• Some applications are written to run on a single computer. All the
services provided by the application.
Two Tier architecture:
In this architecture an application is divided into two components:
a. client: implements the user interface and contains business logic.
b. server: Used to store and access business data captured by the user
interface run on the client in a data store at the server.
Hence in a two-tier architecture,the user interface is always physically
located in the users desktop.
The database management services are always physically on a server.
The server is a always a more powerful machine as it has to service
multiple client requests to store or retrieve data
Three-Tier architecture:
This architecture is basically an evolution of two tier applications.
The application is divided into three layers.
a. User services-Presentation layer: Provides service such as the GUI
and other automation tasks that the application has to perform.
b. Business Service-business layer: Implements business rules.
This layer encapsulates the business logic from users such that they
need not know how business logic is applied.
c. Data Services-Data layer: Provides data availability and integrity.
It is responsible for adding, modifying and deleting data from the data
store.
Multi-tier architecture/N-Tier:
Multi-tier architecture does not prevent the use of two or three tiered
architecture.
Today the industry appears to be rapidly moving towards multi-tier
architecture.
Depending on the scale of the application and the requirements for
access to data, two or three-tiered architecture is often used for
department specific application.
UNIT 2
1. Explain RequestDispatcher interface with its method. (Nov 2018)
Ans)
RequestDispatcher interface defines an object created by Servlet container that
receives request from the client and sends them to any resources such as
Servlet, Html, File or JSP file on the server.
The RequestDispatcher interface provides the facility of dispatching the request
to another resource it may be html, servlet or jsp. This interface can also be
used to include the content of another resource also. It is one of the way of
servlet collaboration.
The RequestDispatcher interface provides two methods. They are:
1) void forward(ServletRequest, ServlerResponse)- Forwards a request from a
servlet to another resource such as Servlet, JSP or HTML file on the server.
2) void include(ServletRequest, ServlerResponse)- Includes the content of a
resource such as Servlet, JSP, HTML file in the response.
2. What is session tracking? What are the ways to track the sessions? (May 19)
Ans)
Session tracking is a mechanism that servlets use to maintain state about a
series of requests from the same user (that is, requests originating from the
same browser) across some period of time.
Sessions are shared among the servlets accessed by a client. This is convenient
for applications made up of multiple servlets. For example, Duke's Bookstore
uses session tracking to keep track of the books being ordered by a user. All the
servlets in the example have access to the user's session.
HTTP is a stateless protocol that provides no way for a server to recognize that
a sequence of request come from the same client. (not even IP Address).
Following are various techniques for session tracking:
1)HTTPSession
2)Cookies
3)URL rewriting
4)Hidden form fields
10. Explain the working of Non-Blocking I/O. (May 19) (Nov 19)
In Java NIO reading and writing are the fundamental process of I/O.
Reading from channel: We can create a buffer and then ask a channel to read the
data.
Writing to channel: We can create a buffer, fill it with data and ask a channel to write
the data.
The core components used in the reading and writing operation are:
•Channels
•Buffers
•SelectorsChannels and Buffers
•In standard I/O API the character streams and byte streamsare used.
•In NIO we work with channels and buffers. All the I/O in NIO is started with a
channel.
Data is always written from a buffer to a channel and read from a channel to a buffer.
Data reading operation:
channels read data into buffer
SelectorsJava NIO provides the concept of "selectors". It is an object that can be used
for monitoring the multiple channels for events like data arrived, connection opened
etc. Therefore single thread can monitor the multiple channels for data
Read Listener: Associates this input stream with a listener object that contains
callback methods to read data asynchronously.
Write Listener: Associates this output stream with a listener object that contains
callback methods to write data asynchronously.