Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF vs JSP + Servlets  RSS feed

 
Marwan Adel
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I would like to ask about the comparison between using JSF and using JSP + Servlets , Why should I favor one of the two technologies over the other?

 
Tim Holloway
Bartender
Posts: 18720
72
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The advantage of JSP+Servlets is that you can construct your webapps any way you want.

The disadvantage of JSP+Servlets is that you must do all the constructing. And debugging - not only of the app, but of whatever framework you develop to support the app. And there won't be any better documentation available for said framework than what you create. Management won't be able to send a temp programmer down to the bookstore to buy a book documenting your framework.

JSF provides a ready-made framework based on the Model/View/Controller (MVC) paradigm that's part of the JEE standard specification and built into JEE-compliant webapp servers. You define the Models (backing beans) and the Views (via View Template files, .xhtml). JSF provides all the Controllers for you, so you don't have to write them. JSF's controllers copy data values from Models to Views and back again, validate input data and report failures, and invoke actions. All of which are very common tasks, so that's much less coding and debugging that you need to do. It does it on a POJO-based architecture so that you don't have to write much code that's JSF-specific, which makes it easier to re-use stuff in non-JSF environments as well as test it offline without the delay and overhead of launching an web application container.

JSF does its best when working with HTML forms. It's at its worst when people attempt to force it to output non-HTML content such as PDF's or Excel spreadsheet files. Fortunately, JSF doesn't require itself to totally own the web application, so it's perfectly acceptable to mix-and-match, using JSF to handle the forms and straight servlets/JSPs for non-HTML work and use mechanism such as session-scope objects to communicate between the different modes.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!