0% found this document useful (0 votes)
50 views

EJ Question Bank

The document provides an overview of Java Enterprise Application architecture and Java concepts like Servlets, JDBC, sessions, and non-blocking I/O. It discusses the different types of application architecture like single tier, two tier, three tier, and multi-tier. It also summarizes the life cycle of a servlet, the RequestDispatcher interface, session tracking techniques, and how non-blocking I/O works using channels, buffers, and selectors in Java NIO.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

EJ Question Bank

The document provides an overview of Java Enterprise Application architecture and Java concepts like Servlets, JDBC, sessions, and non-blocking I/O. It discusses the different types of application architecture like single tier, two tier, three tier, and multi-tier. It also summarizes the life cycle of a servlet, the RequestDispatcher interface, session tracking techniques, and how non-blocking I/O works using channels, buffers, and selectors in Java NIO.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

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.

2. What is CGI? Write its advantages and disadvantages.


During earlier days, the only way dynamic data could be
rendered to the Web was using Common Gateway Interface
(CGI). CGI programs provided a relatively simple way to create
Web applications that accepts user input, queries a database and
returns relevantresults back to the Web browser.Being the most
common of the web technologies almost every leading Web
server in existence today provides support for CGI programs. A
CGI program can be written in many languages such as C, C++,
VB Script, TCL, REXX, Python, Icon, AppleScript, the most
popular being PERL
Advantages: • Language independent.
Disadvantages: • Lack of scalability and reduced speed.
• Each time a request is received by the Web server, an entirely
new process thread is created.
• It was platform dependent.
• A process thread consumes a lot of server-side resources
especially in multi-user situation.
• Difficult for beginners to program modules in this environment.
•Sharing resources such as database connections is between
scripts or multiple calls to the same script was not available,
leading to repeated execution of expensive operations.

5. Explain life cycle of a Servlet. (Nov 2018)

1) init() is called only once when the Servlet is loaded in


memory for the first time and store the
ServletConfig object.
2) service(): After the server loads and initializes the
Servlet, the Servlet is able to handle client requests.
It processes them in service(). Each client’s request
to service() is run in separate Servlet thread.
3) destroy():All resources which were allocated in init()
should be released in destroy(). The method is run
once. The server will not run it again until after it
reloads and reinitializes the Servlet.
4) Servlet lifecycle describes how a servlet works using
the following components:
1)loaded 2)Instantiated 3)Initialized 4)services
request 5) Destroyed 6) Garbage collection
6. Write a short note on JDBC architecture. (Nov 2018) (Nov 2019)
Ans) Java Data Base Connection (JDBC) is an API specification developed by
Sun Microsystems, which defines a uniform set of rulesusing an interface for
accessing different relational databases.JDBC forms a part of the core of the
Java platform and is included in the Java SDK distribution.The singular
purpose of the JDBC API is to provide a resource to developers through which
they can issue SQL statements and process their results in a consistent,
database independent manner.
JDBC defines classes and interfaces, which provide rich, object-oriented access
to database and represent objects such as:
•Database Connections
•SQL statements
•Result sets
•Prepared statements
•Database drivers
•Driver manager

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

Data writing operation:


buffers write data into channel.

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.

You might also like