Differences between JavaServer Faces technology and Struts

By: Charles Emailed: 1606 times Printed: 2079 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

Struts is an open-source Java web application framework whose architecture is based on the Model-View-Controller design pattern in which requests are routed through a controller that provides overall application management and dispatches the requests to application components.  JavaServer Faces technology is a user-interface framework for Java web applications.  It is focussed on the view tier of an MVC-based architecture.  The Struts and JavaServer Faces technology frameworks do have some overlapping functionality; however each framework has its advantages, and developers can use certain features of both frameworks in a single application.

The primary advantages of Struts as compared to JavaServer Faces technology are as follows:

  • Because Struts is a web application framework, it has a more sophisticated controller architecture than does JavaServer Faces technology.  It is more sophisticated partly because the application developer can access the controller by creating an Action object that can integrate with the controller, whereas JavaServer Faces technology does not allow access to the controller.  In addition, the Struts controller can do things like access control on each Action based on user roles.  This functionality is not provided by JavaServer Faces technology.
  • Struts includes a powerful layout management framework, called Tiles, which allows you to create templates that you can reuse across multiple pages, thus enabling you to establish an overall look-and-feel for an application.
  • The Struts validation framework includes a larger set of standard validators, which automatically generate both server-side and client-side validation code based on a set of rules in a configuration file. You can also create custom validators and easily include them in your application by adding definitions of them in your configuration file.

The greatest advantage that JavaServer Faces technology has over Struts is its flexible, extensible UI component model, which includes:

  • A standard component API for specifying the state and behavior of a wide range of components, including simple components, such as input fields, and more complex components, such as scrollable data tables.  Developers can also create their own components based on these APIs, and many third parties have already done so and have made their component libraries publicly available.
  • A separate rendering model that defines how to render the components in various ways.  For example, a component used for selecting an item from a list can be rendered as a menu or a set of radio buttons.
  • An event and listener model that defines how to handle events generated by activating a component, such as what to do when a user clicks a button.
  • Conversion and validation models for converting and validating component data.

Because the JavaServer Faces technology architecture separates the definition of a component from its rendering, you can render your components in different ways or even to different clients, such as a WML client.   Moreover,  the extensible component APIs of JavaServer Faces technology allow you to extend the standard set of components and create entirely new components.  None of this is possible with Struts.  In fact, Struts has no notion of server-side components, which also means that it has no event model for responding to component events and no facility for saving and restoring component state.  While Struts does have a useful tag library for rendering components on the page, these components have no object representation on the server and  they can only be rendered to an HTML client.

Another distinct advantage of JavaServer Faces technology is that it is standard, which means that it has been developed through the Java Community Process (JCP) and has been designed to allow easy integration into tools.  As a result, JavaServer Faces technology already has wide industry support and is being leveraged by several web application development IDEs (such as Sun Java Studio Creator).

Because both JavaServer Faces technology and Struts contribute such valuable features, developers might want to be able to use both of them in a single application.  Developers might want to integrate the flexible component model of JavaServer Faces technology into their existing Struts applications while continuing to use the Struts controller architecture. Similarly, developers who have JavaServer Faces technology applications might want to integrate the more powerful client-side validation mechanism and Tiles layout framework found in the Struts architecture into their applications.  These goals can be accomplished by using the stuts-faces integration library, which you can download from here.


JSF Home | All JSF Tutorials | Latest JSF Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(4)


1. View Comment

Nice one

View Tutorial          By: Kalpana at 2009-11-17 02:04:14
2. View Comment

This is very good Article. On high level I am anbale find what is the difference between struts and jsf. And article also says struts still powerful. So I would like to integrate JSF for my existing struts application.

Thank you.


View Tutorial          By: Sandeep at 2010-08-27 00:40:22
3. View Comment

I liked it.

View Tutorial          By: savitha at 2011-05-06 02:23:46
4. View Comment

JSF's Advantage(3rd point):
"...events generated by activating a component, such as what to do when a user clicks a button"
--could any one pls explain this more elaborately...
with out JSF also if we click the button(say for html <form> submit button) then a new request can be generated & we can get a new page .. so how does JSF make difference from the usual one.


View Tutorial          By: Amit at 2011-07-01 09:38:12

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by Charles
arraycopy example in Java
Action listeners in JSF
Automatically Including Preludes and Codas in JSP
Using realloc() Function in C
Handling multiple buttons in HTML Form in Struts
Fopen and Getc implementation program in C
Pointers to Structures example program in C
Pointers vs. Multi-dimensional Arrays in C
getch and ungetch in C
Bitwise Operators in C
Variables and Arithmetic Expressions in C
Differences between JavaServer Faces technology and Struts
assert() example program in C++
'double buffering' Sample program in J2ME
Converting Default Function Arguments in C++ to Java

More Tutorials in JSF
Struts Vs JSF (A comparison of Struts against JSF)
faces-config.xml to DirectTraffic in the JSF Application
<convertNumber> and <convertDateTime> in JSF
Action listeners in JSF
Calling Multiple Listeners in JSF
Using Javascript in JSF
How to open a new browser window from my JSF page?
Servlet error : java.lang.IndexOutOfBoundsException (JSF RI 1.1_01: IndexOutOfBoundsException)
JSF - TreeNode.setID gets IllegalArgument Exception
Install and Deploy JBoss Application Server
What is JSF (JavaServer Faces)?
Differences between JavaServer Faces technology and Struts
JSF Basics
The Relationship Between JSF and Other Java EE Technologies
JSF Life Cycle

More Latest News
Most Viewed Articles (in JSF )
<convertNumber> and <convertDateTime> in JSF
Install and Deploy JBoss Application Server
Differences between JavaServer Faces technology and Struts
JSF Life Cycle
Controlling Page Navigation in JSF - Static and Dynamic Navigation
Using Javascript in JSF
How to open a new browser window from my JSF page?
Action listeners in JSF
Calling Multiple Listeners in JSF
Struts Vs JSF (A comparison of Struts against JSF)
What is JSF (JavaServer Faces)?
JSF Basics
The Relationship Between JSF and Other Java EE Technologies
Installing JSF
Java Bean Scopes in JSF
Most Emailed Articles (in JSF)
Accessing Context Data in Beans using JSF
What is JSF (JavaServer Faces)?
Servlet error : java.lang.IndexOutOfBoundsException (JSF RI 1.1_01: IndexOutOfBoundsException)
Action listeners in JSF
Calling Multiple Listeners in JSF
Install and Deploy JBoss Application Server
JSF Life Cycle
Java Bean Scopes in JSF
JSF Basics
Installing JSF
Controlling Page Navigation in JSF - Static and Dynamic Navigation
<convertNumber> and <convertDateTime> in JSF
How to open a new browser window from my JSF page?
JSF - TreeNode.setID gets IllegalArgument Exception
faces-config.xml to DirectTraffic in the JSF Application