Saturday, September 11, 2010

Difference Between JSF and Servlet/Jsp

1) JSF is a framework
A framework is just a set of components that allows a developer to build applications more quickly.  A framework provides APIs and classes that the developer uses to build application code.  Any package that fits this description can be called a framework.  As such, the Servlet and JSP packages are frameworks just as JSF is a framework that is built on top of Servlet/JSP frameworks.


2) JSF supports RAD but Servlet/JSP does not
RAD is a buzzword ,butany managers think that any RAD framework will be the next silver bullet that will solve all of there development problems.  This is never true.  Every framework can improve developer productivity after that developer has become fluent in that framework.  If a developer does not get trained in the framework (or technology) then that person will not see any productivity gains by adopted the framework.  This is true of any new technology or framework.

Servlets were the first Java web technology but it was difficult to build HTML views in Java code so Sun created JSPs to make the development of views faster.  After that several independent organizations developed frameworks on top of Servlet/JSP, such as Struts, to make webapp development easier and faster.  Sun took the best ideas and created JSF.  Like these other frameworks JSF is great for some types of applications but not so great for others.
JSF is very good at handling simple forms, tables and even dynamic tree structures. 
JSF also has aspects that hinder rapid development.  In particular there is a lot of configuration (XML files) that need to be generated and maintained.

3) JSF is event-driven but Servlet/JSP does not
This is true.  In practice, JSF event model turns into the standard request/response model.
Servlet/JSP architecture can support fine-grained screen events by using Ajax calls to the server.


4) JSF supports MVC but Servlet/JSP does not
JSF is no better at supporting MVC than a simpler Servlet/JSP architecture.  The MVC pattern takes discipline with any GUI framework. 
JSF is only different in that the controller code is implemented in a regular Java class and not in a Servlet Java class.  That is the only difference.


6) JSF provides a well-defined life cycle model but Servlet/JSP does not
This is true and it is one of the greatest benefits of an architecture based upon JSF.
A Servlet/JSP architecture must build its own life cycle.  This is usually quite easy but it does take effort and discipline.

7) JSF life cycle model supports validation but Servlet/JSP does not
This is true, but there is nothing about a Servlet/JSP architecture that prevents validation;

8) JSF has built-in support for I18N but Servlet/JSP does not
While it is true that JSF has built-in support for internationalization (abbreviated as I18N), it is not exactly true to say that Servlet/JSP does not.  JSTL libraries includes I18N support.