As all JSPs are generated / translated to Servlets before their execution, is its true for Facelets too?
I am working with JSF 2.0 and Facelets and wanted to see its generated Java Code which might be Servlet.
Servlets are faster as compared to JSP, as they have a short response time. JSP is slower than Servlets, as the first step in the JSP lifecycle is the conversion of JSP to Java code and then the compilation of the code. Servlets are Java-based codes. JSP are HTML-based codes.
JSF is a web-based application that is used to simplify the development integration of web-based user interfaces. While JSP is a Java-based technology used respectively in order to support software developers create dynamic web pages. JSP must be compiled in Java bytecode in order to work properly.
Facelets views are usually created as XHTML pages. JavaServer Faces implementations support XHTML pages created in conformance with the XHTML Transitional DTD, as listed at http://www.w3.org/TR/xhtml1/#a_dtd_XHTML-1.0-Transitional. By convention, web pages built with XHTML have an . xhtml extension.
Servlets are written in the Java language. JSPs on the other hand use a combination of HTML and Java. Eventually JSPs are converted into a pure Java servlet.
No, Facelets files are parsed to a XML tree using a SAX parser. The XML tree is stored in the Facelet cache. The XML tree is during view build time turned into an UIComponent
tree which is accessible by FacesContext#getViewRoot()
(which you can traverse by getChildren()
during runtime). The component tree normally generates HTML code by their own encodeXxx()
methods or the ones on the associated Renderer
, starting with UIViewRoot#encodeAll()
.
Facelets files do not generate any class files. The XML trees are by default stored in server's memory. Since JSF 2.1 you can however specify a custom FaceletCache
implementation by <facelet-cache-factory>
in faces-config.xml
wherein you can write code to store the XML tree on for example the disk file system (which would be slower, though).
If you use <ui:debug>
in the view and open it, then you can see the textual representation of the component tree behind UIViewRoot
. See also how to debug JSF/EL
Not exactly the same way, it gets cached. But it doesn't generate servlet code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With