I am currently doing a client-side redirect to get from a legacy servlet (old part of an application) to a JSF page (new part of an application). I would prefer to do a server-side redirect if possible, so that I may place items in the request that the JSF page can pick up. (there is a set of data that needs to be “handed off” between the legacy servlet and the JSF page and I prefer not to put these in a client-side redirect URL (as URL parameters) but instead do this on the server-side).
If there is a way to do a server-side redirect between a servlet (not the Faces servlet) and a JSF page, can you please show me how?
Just call
RequestDispatcher#forward()the usual way. All servlets intercept on forwarded requests as well. You just need to make sure that the forward path matches theFacesServletmapping. Assuming that you’ve mapped it on*.xhtml, this should do:The page can if necessary be placed in
/WEB-INFfolder if you want to prevent the endusers from being able to open it directly without invoking the servlet first.