3 Replies Latest reply: Jun 26, 2012 2:30 AM by gimbal2 RSS

    JSF 1.2 lifecycle details

    Nico
      Hi all, I would like to ask 2 questions on JSF 1.2 lifecycle:

      All the requests for jsf resources are managed by the FacesServlet whose service method starts the lifecycle for the requested resource. So, for each request:

      the web container creates a new thread to serve the request
      the thread calls the service method of the FacesServlet which starts jsf lifecycle
      the whole lifecylce takes place into the thread

      Is this correct?

      JSF pages are translated into servlet at a certain point of the lifecycle or not? Talking about the Render Response Phase, the JavaEE 5 tutorial says: "During this phase, the JavaServer Faces implementation delegates authority for rendering the page to the JSP container if the application is using JSP pages ..... the components will render themselves as the JSP container traverses the tags in the page."

      Does it mean that the response is constructed one tag at a time while the jsp container traverses the whole view without the need to translate the page into a servlet and call the resulting jsp_service method (as for standard jsp pages)?

      Thanks a lot for your help,

      Nico
        • 1. Re: JSF 1.2 lifecycle details
          gimbal2
          >
          Yes, the server will likely have a thread per request although it is not strictly necessary when it uses NIO under the hood. The only thing you have to worry about is that a request is handled isolated from all others. That is not JSF specific in any way.
          JSF pages are translated into servlet at a certain point of the lifecycle or not? Talking about the Render Response Phase, the JavaEE 5 tutorial says: "During this phase, the JavaServer Faces implementation delegates authority for rendering the page to the JSP container if the application is using JSP pages ..... the components will render themselves as the JSP container traverses the tags in the page."
          JSP pages are translated into servlets; again not related to JSF. You may use JSPs as the view technology for JSF but I would recommend using Facelets in stead.
          Does it mean that the response is constructed one tag at a time while the jsp container traverses the whole view without the need to translate the page into a servlet and call the resulting jsp_service method (as for standard jsp pages)?
          No, that's not what it says at all. Basically all it says is that the JSP renderer will trigger the JSF components to render and not JSF itself.
          • 2. Re: JSF 1.2 lifecycle details
            Nico
            Hi gimbal, thanks a lot for your help but I'm not sure to understand if jsf pages are translated into servlet when using JSP as the view technology for JSF. Could you please tell me if my interpretation is correct:

            when using JSP as view technology for JSF, the jsp page is still translated into a servlet during jsf lifecycle. Once the servlet is ready, the original thread created by the web container calls the resulting jsp_service method in order to provide a response to the client.

            Thanks again,
            Nico
            • 3. Re: JSF 1.2 lifecycle details
              gimbal2
              Well almost. The jsp_service call will be part of the normal servlet execution, which is during the invocation of doGet or doPost based on what method the request has (GET, POST). The server doesn't do anything special other than run the servlet like any other servlet.

              EDIT:

              note that most if not all servers keep the generated .java source file somewhere, usually in a 'work' subdirectory. You could check out what the server generates yourself.