Monday, November 09, 2009

Redirect from Struts Action

request.sendRedirect does not work in Struts action. You can use it in jsp (view layer) but not in the Struts Action

Action:-

request.setAttribute("url", "http://dynamic_url.com");

return mapping.findForward("redirect");

struts-config.xml

</global-forwards>

<forward name="redirect" path="/redirect.jsp" redirect="false" />

</global-forwards>

redirect.jsp

<% String url = (String)request.getAttribute("url");

response.sendRedirect(url);

%>


No comments:

Post a Comment

Thank you for your feedback