How all JSPs are generated / translated into Servlets before they are executed, is this true for Facelets?
I work with JSF 2.0 and Facelets and want to see its generated Java code, which may be Servlet.
No, Facelets files are parsed in the XML tree using SAX parser . The XML tree is stored in the Facelet cache . The XML tree is at the time to see the build time turned into a UIComponent , which is accessible by FacesContext#getViewRoot() (which you can pass getChildren() at runtime). The component tree typically generates HTML using either the native encodeXxx() methods or those associated with the Renderer , starting with UIViewRoot#encodeAll() .
UIComponent
FacesContext#getViewRoot()
getChildren()
encodeXxx()
Renderer
UIViewRoot#encodeAll()
Facelets file files do not generate class files. XML trees are stored in server memory by default. Starting with JSF 2.1, you can specify FaceletCache using <facelet-cache-factory> in faces-config.xml , where you can write code to store the XML tree, for example, to a file system on disk (although this would be slower).
FaceletCache
<facelet-cache-factory>
faces-config.xml
If you use <ui:debug> in the view and open it, you will see a text view of the component tree behind the UIViewRoot . See Also How to Debug JSF / EL
<ui:debug>
UIViewRoot
Not really, it is cached. But it does not generate servlet code.