2

JSF can use JSP as the view definition language.

From my understanding of what JSP does is: it generates a java class that implements the servlet interface. When this servlet is called it writes to the response object (that is send to the servlet client).

If it just writes to the response object then how is the UIViewRoot populated?

How about the render phase, what is left for it to do if the JSP had already write to the response?

Pedro Custódio
  • 834
  • 10
  • 20

1 Answers1

2

It are the <f:xxx> and <h:xxx> tags which do the magic. The <f:view> tag represents the UIViewRoot. Everthing inside this tag is handled by JSF renderers, not by JSP. JSP just executes the body of the tag which in turn delegates to all the JSF works. JSP doesn't print the tag plain vanilla to the response (rightclick page in browser and do View Source, there should be no single JSF tag in there, but only its HTML output).

To learn more about "custom" JSP tags, check the Java EE 5 tutorial.

Note that in JSP's successor Facelets the <f:view> is not mandatory, it's already implicitly used.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Ok, I get that the and tags would populate the UIViewRoot, but what about the other tags/text, would they not write to directly to the servlet response, like the doctype and the write statement next:

    <%="Hello World!" %>

    – Pedro Custódio May 22 '12 at 14:43
  • 1
    Anything outside `` is handled by standard JSP writer. – BalusC May 22 '12 at 14:47