Struts 1.3: forward outside the application context?
Question
Struts 1.3 application. Main website is NOT served by struts/Java. I need to forward the result of a struts action to a page in the website, that is outside of the struts context. Currently, I forward to a JSP in context and use a meta-refresh to forward to the real location. That seems kinda sucky. Is there a better way?
Solution
You can't "forward", in the strict sense. Just call sendRedirect()
on the HttpServletResponse
object in your Action
class's execute()
method and then, return null
.
Alternately, either call setModule()
on the ActionForward
object (that you are going to return) or set the path to an absolute URI.
OTHER TIPS
I ended up doing response.sendRedirect().
If this was still in the web application, you could use ServletContext.RequestDispatcher? That's how the Struts doForward() method works. However, to go outside Struts/Java, you need the sendRedirect().
RequestDispatcher rd = getServletContext().getRequestDispatcher(uri);
rd.forward(request, response);