Sunday 9 August 2015

JSP vs XHTML

True, JSP has some templating capabilities, but the biggest disadvantage of using JSP in JSF is that JSP writes to the response as soon as it encounters template text content, while JSF would like to do some pre/post processing with it. In JSF 1.0/1.1 the following JSF code

<h:outputText value="first"> second <h:outputText value="third"> fourth
would produce

second fourth first third

==============================================
SP Compile-Time Overhead

Every time you edit, save and reload a JSP page, the server's JSP compiler generates Java servlet code and compiles it into a servlet. This is called the JSP translation process, and typically it costs between 1-2 seconds, depending on server performance.

Facelets XML Compilation

Unlike JavaServer Pages, Facelets pages are not compiled into servlets. Since Facelets pages are XML-compliant, the Facelets framework uses a fast SAX-based compiler to build your views. Also, Facelets can be configured to detect and render changes to your pages immediately, speeding up your JSF development cycle.
Book "JSF 1.2 components" from Ian Hlavats, page 49:

During JSF application development, we often make changes to our JSF pages, resulting in frequent recompilation of our JSP pages, and this compile-time overhead can add up.

Facelets pages are simple XML documents (XHTMl pages) that are never compiled to servlets rather it uses the SAX-based compilation process that constructs the UI component tree for our views. Hence Facelets are faster compared to JSP since it is free from the JSP translation overhead.

2 comments:

  1. As we know there are many companies which are converting into Big data service providers. with the right direction we can definitely predict the future.

    ReplyDelete