Well, if you want to get a response object, you can get it in JSF , as shown below:
HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
But you really don't need to get a response object just for redirection outside of JSF . This can be done more easily with the following:
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); externalContext.redirect("http://www.example.com/myJspPage.jsp");
Edit
If you use any non-action method, you can use any of the above! But when you are in any action , the correct JSF redirection method is:
public String goToOutsideAction(){ .... return "/myPage.xhtml?faces-redirect=true" }
The method should return a context-specific view identifier, and the target should be a JSF page.
source share