Reputation: 12876
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?
Upvotes: 4
Views: 5990
Reputation: 1108802
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 the FacesServlet
mapping. Assuming that you've mapped it on *.xhtml
, this should do:
request.getRequestDispatcher("/page.xhtml").forward(request, response);
The page can if necessary be placed in /WEB-INF
folder if you want to prevent the endusers from being able to open it directly without invoking the servlet first.
request.getRequestDispatcher("/WEB-INF/page.xhtml").forward(request, response);
Upvotes: 3