nerdexam
Oracle

1Z0-900 · Question #19

When handling a JSF request, your application code decided to redirect the call to another URL by using HTTP redirect. Which action should you take to correctly complete the handling of the JSF life…

The correct answer is C. Invoke the setCurrentPhaseId(RENDER_RESPONSE) method on the FacesContext object. Important note: The provided correct answer (C) appears to be incorrect based on standard JSF documentation. D is the actual correct answer. When application code issues an HTTP redirect, the response has already been committed to the client. Calling…

Develop Web Applications using JSFs

Question

When handling a JSF request, your application code decided to redirect the call to another URL by using HTTP redirect. Which action should you take to correctly complete the handling of the JSF life cycle?

Options

  • ASet the immediate="true" attribute on the command button that was used to perform this call.
  • BInvoke the dispatch() method on the ExternalContext object.
  • CInvoke the setCurrentPhaseId(RENDER_RESPONSE) method on the FacesContext object.
  • DInvoke the responseComplete() method on the FacesContext object.

How the community answered

(64 responses)
  • A
    3% (2)
  • B
    16% (10)
  • C
    75% (48)
  • D
    6% (4)

Explanation

Important note: The provided correct answer (C) appears to be incorrect based on standard JSF documentation. D is the actual correct answer.

When application code issues an HTTP redirect, the response has already been committed to the client. Calling FacesContext.responseComplete() (option D) signals to the JSF runtime that the response is complete and the remaining lifecycle phases should be skipped - this is the standard, documented pattern for this scenario. Option C (setCurrentPhaseId(RENDER_RESPONSE)) only mutates a metadata value on FacesContext; it does not halt lifecycle processing, so JSF will continue executing phases against a response that has already been sent, which is incorrect. Option B (ExternalContext.dispatch()) performs a server-side forward, not a redirect completion - and dispatch() isn't the right method here anyway. Option A (immediate="true") short-circuits validation and model updates on the way into the lifecycle, and has no bearing on redirect handling.

Memory tip: Think of responseComplete() as telling JSF "we're done here - I've already handled the response, don't touch it." Any time you manually write to or redirect the response outside of normal JSF rendering, responseComplete() is your cleanup call.

Summary: Double-check the source of this question - answer D (responseComplete()) is what Oracle's JSF specification and all major JSF references prescribe for this scenario. If this is from a practice exam, it may contain an error.

Topics

#JSF Lifecycle#FacesContext Methods#HTTP Redirect#Phase Control

Community Discussion

No community discussion yet for this question.

Full 1Z0-900 Practice