tags:

views:

1085

answers:

3

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?

+1  A: 

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

shrisha
My understanding is that an absolute URI that doesn't include the host/port is always considered relative to the app context.What does setModule() do? It's not clearly documented, and seems like "/whatever" is still relative to the app context?
davetron5000
A: 

I ended up doing response.sendRedirect().

davetron5000
A: 

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);
Kevin Hakanson
I don't think it lets you go outside the context of the webapp....
davetron5000
You're right - I misread the question. I will edit my answer, but leave for completeness.
Kevin Hakanson