J2ee Advantages and Disadvantages

For Job Interviews


1) Struts:


Model View Controller (MVC2:- change in the model doesn’t cause a change in the view)

Struts tags

Tiles: Common look and feel

Validation Framework


No rich UI Components.

All the logic is in the action classes and so tighly coupled

Struts screens can’t be rendered in different manner on a computer screen and pda.

2) JSF


Rich UI Components: – There would be classes for buttons and other things and we get a lot of rich UI functionality

All the navigation logic is in the faces-config.xml file and so loose coupling

There is a renderer class so the look and feel of the jsp page would be different in the pda and computer screen

JSF will give a identifier to each view and so the next time the request is made the view is already in the cache and so fast access

Very rich validations can be written and no need to create separate xml files for them like struts. All things are done in the faces-config.


Dependent on using JSPs like Struts

There is no Tiles framework like Struts for look and feel.

3) Spring MVC:


Dependency injection: Directly we can use the DAO’s in the JSP pages

Very rich Spring tags

View Agnostic: The JSP’s can be replaced by Velocity,PHP and other things.

It has different types of controllers like SimpleFormController,CommandController and all and each does a
specialized task.

Avoid Forced Concrete Inheritance:
Spring MVC does not force your model to inherit any custom classes related to Spring. It does all its work through interfaces. This helps in a way that once can inherit from a standard Java class. It also helps in testing, as it would rather difficult to test or resuse an object which is extending another custom one.


No workflow like arrangement.

4) Spring Webflow:

Workflow is defined in one xml file

Variables can be passed from one page to other without one explicitely coding anything.

5) Hibernate:


ORM: Object Relational Modelling

In Hibernate there is caching either at the session level or the sessionFactory level. We can also add furhter caching.

By changing one line in the xml file one can change the database and the code is unchanged.

HQL is simpler than SQL.

We can improve the performance by having suitable loading and fetching strategies(should the dependencies be loaded all at once or in batch)

 We have the inbuilt database and plus functions for debugging.


What if we don’t know the entire table structure?

As it makes use of xml sometimes there are portability issues.

6) Spring:


1) Dependency Injection: Central to the Spring Framework is its Inversion of Control container, which provides a consistent means of configuring and managing Java objects using callbacks. The container is responsible for managing object lifecycles: creating objects, calling initialization methods, and configuring objects by wiring them together.
a) You can specify which method of the bean has to be called after bean is created “init-method”
and which method before bean is destroyed(destroy-method).
b)  Spring provides a core factory pattern, which eliminates the need to manually program factory   objects   (usually realized as singletons). The fundamental benefit of the Spring framework is its ability to act as a factory to create objects. Spring reads a schematic defined in an external configuration file, creates and wires the objects together using reflection, and then passes the objects back to you. Think of Spring as a factory that you don’t have to write any code for. It also allows you to decouple the configuration and specification of dependencies from your actual program logic.
Ref: http://en.wikipedia.org/wiki/Spring_framework

2) Has many modules(7) and so things can be plugged in

7) Maven:


For all users to have uniform project structure

Jar files are kept in repository and so one need not add them to cvs

pom.xml is easier to edit

8) Restful webservices:

Web is HTTP based. So Restful deals with HTTP architecture and treats each object indivually as a service. So for read it will use GET(cache and safe) and for update,delete and all it will use POST,DELETE so on.
Definitely faster and easier to develop.