0% found this document useful (0 votes)
71 views11 pages

Basic Components of J2EE

The document discusses the basic components of J2EE, which are application clients and applets as client components, Java servlets and JSPs as web components, enterprise beans as business components, and resource adapter components. It also discusses J2EE modules like application client, web, EJB, and resource adapter modules. The document then asks questions about deployment descriptors, differences between session and entity beans, and other J2EE concepts.

Uploaded by

Suraj
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)
71 views11 pages

Basic Components of J2EE

The document discusses the basic components of J2EE, which are application clients and applets as client components, Java servlets and JSPs as web components, enterprise beans as business components, and resource adapter components. It also discusses J2EE modules like application client, web, EJB, and resource adapter modules. The document then asks questions about deployment descriptors, differences between session and entity beans, and other J2EE concepts.

Uploaded by

Suraj
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/ 11

Basic Components of J2EE

As we are starting to learn J2EE the most basic question in J2EE interview questions is what are
the components of J2EE and if we look for the answer we will find four components-
Application clients and applets are client components, Java Servlet and JavaServer PagesTM
(JSPTM) technology components are web components, Enterprise JavaBeansTM (EJBTM)
components (enterprise beans) are business components and Resource adapter components
provided by EIS and tool vendors. These basic components of J2EE help it to develop the
application but there are thousands of other components in J2EE too

In J2EE one component is made of one or more than one module and to create a component you
will find four basic modules in J2EE – Application client module, Web module, Enterprise
JavaBeans module and Resource adapter module. These modules contain various types of files
like in an Application client module you will find an application client deployment descriptor,
class files and the files are saved with .jar extensions and on the other side GIF and HTML files,
SP files, class files for servlets and a Web deployment descriptor are inside Web module.
Module is a very important part of J2EE and there are lots of important J2EE interview
questions that you must know.

What is a Deployment Descriptor in J2EE?


In J2EE interview questions it is a very important question and it is asked in many interviews.
The deployment descriptor gives a path to a project developed in J2EE modules and it enables
the project to run in business logic. When we are developing web applications using Java these
files must be called inside web.xml and in the WEB-INF directory in the web application root
files. Especially in Java EE applications these deployment descriptors are must enabled
with application.xml and should be placed inside the META-INF directory at the top level Java
file and it extension as .ear file.

Learn about the Differences about Session Bean and Entity Bean

As we are progressing in our course other important J2EE interview questions are also coming
up like the differences between Session bean and Entity bean. There are two types of Session
beans – stateless and stateful beans which are used to calculate or access the database for the
client and it can be destroyed by the client. On the other hand an Entity bean represents persistent
data which is inside a database and it can survive the crash down of its container host.

1) What is J2EE?
J2EE means Java 2 Enterprise Edition. The functionality of J2EE is developing multitier
web-based applications .The J2EE platform is consists of a set of services, application
programming interfaces (APIs), and protocols.
2) What are the four components of J2EE application?
 Application clients components.
 Servlet and JSP technology are web components.
 Business components (JavaBeans).
 Resource adapter components
3) What are types of J2EE clients?
 Applets
 Application clients
 Java Web Start-enabled clients, by Java Web Start technology.
 Wireless clients, based on MIDP technology.
4) What are considered as a web component?
Java Servlet and Java Server Pages technology components are web components.
Servlets are Java programming language that dynamically receive requests and make
responses. JSP pages execute as servlets but allow a more natural approach to creating
static content.
5) What is JSF?
JavaServer Faces (JSF) is a user interface (UI) designing framework for Java web
applications. JSF provide a set of reusable UI components, standard for web
applications.JSF is based on MVC design pattern. It automatically saves the form data to
server and populates the form date when display at client side.
6) Define Hash table
HashTable is just like Hash Map,Collection having key(Unique),value pairs. Hashtable is a
collection Synchronozed object .It does not allow duplicate values but it allows null values.
7) What is Hibernate?
Hibernate is a open source object-relational mapping and query service. In hibernate we
can write HQL instead of SQL which save developers to spend more time on writing the
native SQL. Hibernate has more powerful association, inheritance, polymorphism,
composition, and collections. It is a beautiful approach for persisting into database using the
java objects. Hibernate also allows you to express queries using java-based criteria .
8 ) What is the limitation of hibernate?
 Slower in executing the queries than queries are used directly.
 Only query language support for composite keys.
 No shared references to value types.
9) What are the advantage of hibernate.
 Hibernate is portable i mean database independent, Vendor independence.
 Standard ORM also supports JPA
 Mapping of Domain object to relational database.
 Hibernate is better then plain JDBC.
 JPA provider in JPA based applications.
10) What is ORM?
ORM stands for Object-Relational mapping. The objects in a Java class which is mapped in
to the tables of a relational database using the metadata that describes the mapping
between the objects and the database. It works by transforming the data from one
representation to another.
11) Difference between save and saveorupdate
save() – This method in hibernate is used to stores an object into the database. It insert an
entry if the record doesn’t exist, otherwise not.
saveorupdate () -This method in the hibernate is used for updating the object using identifier.
If the identifier is missing this method calls save(). If the identifier exists, it will call update
method.
12) Difference between load and get method?
load() can’t find the object from cache or database, an exception is thrown and the load()
method never returns null.
get() method returns null if the object can’t be found. The load() method may return a proxy
instead of a real persistent instance get() never returns a proxy.
13) How to invoke stored procedure in hibernate?
{ ? = call thisISTheProcedure() }
14) What are the benefits of ORM?
 Productivity
 Maintainability
 Performance
 Vendor independence
15) What the Core interfaces are of hibernate framework?
 Session Interface
 SessionFactory Interface
 Configuration Interface
 Transaction Interface
 Query and Criteria Interface
16) What is the file extension used for hibernate mapping file?
The name of the file should be like this : filename.hbm.xml
17) What is the file name of hibernate configuration file?
The name of the file should be like this : hibernate.cfg.xml
18) How hibernate is database independent explain?
Only changing the property
[xml]
<property name=”hibernate.dialect”>org.hibernate.dialect.Oracle9Dialect</property> and
<property
name=”hibernate.connection.driver_class”>oracle.jdbc.driver.OracleDriver</property>
[/xml]
full database can be replaced.
19) How to add hibernate mapping file in hibernate configuration file?
By <mapping resource=” filename.hbm.xml”/>
20) Define connection pooling?
Connection pooling is a mechanism reuse the connection.which contains the number of
already created object connection. So whenever there is a necessary for object, this
mechanism is used to directly get objects without creating it.
21) What is the hibernate proxy?
An object proxy is just a way to avoid retrieving an object until you need it. Hibernate 2 does
not proxy objects by default.
22) What do you create a SessionFactory?
[java]
Configuration cfg = new Configuration();
cfg.addResource(“dir/hibernate.hbm.xml”);
cfg.setProperties( System.getProperties() );
SessionFactory sessions = cfg.buildSessionFactory();
[/java]
23) What is HQL?
HQL stands for Hibernate Query Language. Hibernate allows to the user to express queries
in its own portable SQL extension and this is called as HQL. It also allows the user to
express in native SQL.
24) What are the Collection types in Hibernate ?
Set, List, Array, Map, Bag
25) What is a thin client?
A thin client is a program interface to the application that does not have any operations like
query of databases, execute complex business rules, or connect to legacy applications.
26) Differentiate between .ear, .jar and .war files.
.jar files: These files are with the .jar extenstion. The .jar files contains the libraries,
resources and accessories files like property files.
.war files: These files are with the .war extension. The .war file contains jsp, html, javascript
and other files for necessary for the development of web applications.
.ear files: The .ear file contains the EJB modules of the application.
27) What are the JSP tag?
In JSP tags can be divided into 4 different types.
 Directives
 Declarations
 Scriplets
 Expressions
28) How to access web.xml init parameters from jsp page?
For example, if you have:
<context-param> <param-name>Id</param-name> <param-value>this is the value</param-
value></context-param>
You can access this parameter
Id: <h:outputText value=”#{initParam['Id']}”/>
29) What are JSP Directives?
 1.page Directives <%@page language=”java” %>
 2. include Directives: <%@ include file=”/header.jsp” %>
 3. taglib Directives <%@ taglib uri=”tlds/taglib.tld” prefix=”html” %>
30) What is the EAR file?
An EAR file is a JAR file with an .ear extension. A J2EE application with all of its modules is
delivered in EAR file.
31) What will happen when you compile and run the following code?
[java]
public class MyClass {
public static void main(String argv[]){
int array[]=new int[]{1,2,3};
System.out.println(array [1]);
}
}
Answer:
Compiled and shows output : 2
[/java]
32) What is Struts?
Struts framework is a Model-View-Controller(MVC) architecture for designing large scale
applications. Which is combines of Java Servlets, JSP, Custom tags, and message. Struts
helps you to create an extensible development environment for your application, based on
published standards and proven design patterns. Model in many applications represent the
internal state of the system as a set of one or more JavaBeans.The View is most often
constructed using JavaServer Pages (JSP) technology.The Controller is focused on
receiving requests from the client and producing the next phase of the user interface to an
appropriate View component. The primary component of the Controller in the framework is
a servlet of class ActionServlet. This servlet is configured by defining a set
of ActionMappings.
33.What is ActionErrors?
ActionErrors object that encapsulates any validation errors that have been found. If no
errors are found, return null or an ActionErrors object with no recorded error messages.The
default implementation attempts to forward to the HTTP version of this method. Holding
request parameters mapping and request and returns set of validation errors, if validation
failed; an empty set or null
34) What is ActionForm?
ActionForm is a Java bean that associates one or more ActionMappings. A java bean
become FormBean when extend org.apache.struts.action.ActionForm class. ActionForm
object is automatically populated on the server side which data has been entered by the
client from UI. ActionForm maintains the session state for web application.
35) What is action mapping??
In action mapping we specify action class for particular url ie path and diffrent target view ie
forwards on to which request response will be forwarded.The ActionMapping represents the
information that the ActionServlet knows about the mapping of a particular request to an
instance of a particular Action class.The mapping is passed to the execute() method of
theAction class, enabling access to this information directly.
36) What is the MVC on struts.
MVC stands Model-View-Controller.
Model: Model in many applications represent the internal state of the system as a set of one
or more JavaBeans.
View: The View is most often constructed using JavaServer Pages (JSP) technology.
Controller: The Controller is focused on receiving requests from the client and producing
the next phase of the user interface to an appropriate View component. The primary
component of the Controller in the framework is a servlet of class ActionServlet. This
servlet is configured by defining a set of ActionMappings.
37) What are different modules in spring?
There are seven core modules in spring
 The Core container module
 O/R mapping module (Object/Relational)
 DAO module
 Application context module
 Aspect Oriented Programming
 Web module
 MVC module
38) What is Bean Factory, have you used XMLBean factory?
[java]
XmlBeanFactory is one of the implementation of bean Factory
org.springframework.beans.factory.xml.XmlBeanFactory is used to creat bean instance
defined in our xml file.
BeanFactory factory = new XmlBeanFactory(new FileInputStream(“beans.xml”));
Or
ClassPathResource resorce = new ClassPathResource(“beans.xml”);
XmlBeanFactory factory = new XmlBeanFactory(resorce);
[/java]
39) What is Spring?
Spring is a light weight open source framework for the development of enterprise
application that resolves the complexity of enterprise application development also
providing a cohesive framework for J2EE application development. Which is primarily based
on IOC (inversion of control) or DI (dependency injection) design pattern.
40) Functionality of ActionServlet and RequestProcessor?
 Receiving the HttpServletRequest
 Populating JavaBean from the request parameters
 Displaying response on the web page Issues
 Content type issues handling
 Provide extension points
41) ActionServlet, RequestProcessor and Action classes are the components of
Controller
42) What is default scope in Spring?
Singleton.
43) What are advantages of Spring usage?
 Pojo based programming enables reuse component.
 Improve productivity and subsequently reduce development cost.
 Dependency Injection can be used to improve testability.
 Spring required enterprise services without a need of expensive application server.
 It reduces coupling in code and improves maintainability.
44)What are the Benefits Spring Framework ?
 Light weight container
 Spring can effectively organize your middle tier objects
 Initialization of properties is easy ? no need to read from properties file
 application code is much easier to unit test
 Objects are created Lazily , Singleton – configuration
 Spring’s configuration management services can be used in any architectural layer, in whatever
runtime environment
45) Lifecycle interfaces in spring ?
[java]
1) InitializingBean
<bean id=”expInitBean” init-method=”init”/>
public class ExpBean {
public void init() { // do some initialization code }
}
OR
<bean id=” expInitBean “/>
public class ExpBean implements InitializingBean {
public void afterPropertiesSet() { // do some initialization code }
}
2) DisposableBean
<bean id=”expInitBean” destroy-method=”cleanup”/>
public class ExpBean {
public void cleanup() {
// do some destruction code (like releasing pooled connections)
}}
OR
<bean id=”expInitBean”/>
public class ExpBean implements DisposableBean {
public void destroy() { // do some destruction code (like releasing pooled connections) }
}
[/java]
46) How to Create Object without using the keyword “new” in java?
Without new the Factory mehtods are used to create objects for a class. For example
Calender c=Calender.getInstance();
here Calender is a class and the method getInstance() is a Factory method which can
create object for Calender class.
47) What is servlet?
Servlets is a server side components that provide a powerful mechanism for developing
server side programs. Servlets is a server as well as platform-independent and Servlets are
designed for a various protocols. Most commonly used HTTP protocols. Servlets uses the
classes in the java packages javax.servlet, javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse, javax.servlet.http.HttpSession;. All servlets must
implement the Servlet interface, which defines life-cycle methods.
48) Servlet is pure java object or not?
Yes, pure java object.
49) What are the phases of the servlet life cycle?
The life cycle of a servlet consists of the following phases:
 Servlet class loading
 Servlet instantiation
 the init method
 Request handling (call the service method)
 Removal from service (call the destroy method)
50) What must be implemented by all Servlets?The Servlet Interface must be implemented by
all servlets.

posted Tuesday, April 19, 2011 15:09


Posts:
1

J2EE - Java 2 Enterprise Edition is one of the 3 java platforms, the other being J2SE and J2ME. It is
set of specifications or standards consisting of many APIs useful for building java based enterprise
applications. At such it is not some software to be installed but is just a bundle of many
technologies having set of APIs.

J2EE applications are java applications that span over LAN, WAN and broader. They are used when
it comes to distributed environment and disparate systems and also when in need to make use of
its technologies.

J2EE technologies are broadly classified into two categories:


1. Component technologies
2. Service technologies

Kinds of J2EE Components:


Client Side Comonents -> includes applets.
Web Components -> includes servelets and JSPs
Business Components -> includes EJB
Web components and Business components run on Server Side...
Kinds of J2EE Services:
JNDI -> Java Naming and Directory service
JMS -> java Messaging Service
JTA -> Java Transaction API
JAAS -> Java Authentication and Authorization Service
Java Mail

J2EE is meant for building the 3 layers of java based enterprise application. The layers being:
1. Presentation Layer
2. Service/Business Layer
3. Data Access Layer

We have been talking on java based enterprise application... To clear you on it:
A computer application used to manage business services of an enterprise is called enterprise
application and if the application is coded in java and is deployed into J2EE compliant application
server then it becomes java based.

Any enterprise application generally covers 4 main tasks:


1. providing user interface(UI) to the user.
2. processing of data according to some business logic(rules)
3. interacting with database(data access)
4. storing of data
These tasks are logically divided into 4 layers
A. Presentation layer
B. Business/Service layer
C. Data Access Layer
D. Data Layer

J2EE developers are responsible for the first 3 layers while the data layer is the responsibility of
database administrator(DBA). Hope you are clear on the layers... Remember they are just the
logical division. Now coming to actual or physical division...
The physical partition of enterprise application is known as 'tier'. The enterprise application can
be single-tier, two-tier, three-tier, n-tier or distributed-tier depending on number of computing
systems on which the layers are installed.

Presentation Layer is the user interface part of the application. If the app is web based then
Servelets and JSPs are used to build it on server side. The main design patterns used in this layer
are Front Controller, Model-View-Controller(MVC), Composite View.

Business/Service Layer is nothing but a code that processes data according to business
logic(rules). Some important design patterns used in this layer are Service Locator, Business
Delegate, Session Facade. Job of service layer is to receive the business request from presentation
layer or some other service layer, communicate with data access layer to get the enterprise data,
process that data using defined business rules, return the result to the requested component

Data Access layer is again a code which communicates with the database. It performs
CRUD(Create, Read, Update, Delete). Therefore it is just a code communicating with database
specific APIs such as JDBC. The design patterns used are Data Access Object(DTO), Data Transfer
Object(DTO), Value Object. Can you guess what its job is??? It receives request from service layer,
communicates with the database to perform the requested operations and sends the result back
to service layer.

So now you clear on J2EE basics

We already know what is the job of service layer but in order for it to implement it, it needs some
capabilities... like transactional capability, distributed computing capability, security
implementation capability.
To have these capabilities we make use of J2EE technologies(both components and services). Just
scroll up and read the first three paragraphs... This should make it clear for you.

You might also like