Criteria for choosing Struts or JavaServer Faces
When you create applications in a dynamic Web project, JavaServer Faces and Struts are technologies that you can use with or without JavaServer Pages (JSP). The following table gives guidance to help you choose.
Either Struts or JavaServer Faces can provide a useful framework for developing dynamic Web applications. Consider the following table which compares JavaServer Faces, JavaServer Pages, and JSP and Struts.
JavaServer Faces JavaServer Pages JSP and Struts Components
- Rich UI-data-bound components with events provided
- Custom components
- Standard tags (JSTL) that are non-UI and very basic
- Custom components through tag libraries
- Struts-specific tag library
- Only very basic, form-bean-bound components provided
Device independence
- Reader kits that provide device independence
- None
- None
Error handling and validation
- Validation framework
- Many predefined validators
- None
- Validation framework driven by an XML file (validation.xml)
Scripting
- Scripts can be attached to events
- All components accessible from scripts
- Embedded Java in the page
- Scripts written in Java Action classes
- Form data but not components accessible
Page flow
- Simple navigation file (faces-config.xml)
- None
- Sophisticated, flexible framework
- XML file based
Session and object management
- Automatic
- Manual
- Manual
Related concepts
JavaServer Faces
Struts: a framework for developing Web applications
Struts-based Web applications
Related tasks
Creating well-architected Web applications using Struts
Creating Faces applications - overview
Related reference
Books about JavaServer Faces
Books about Struts