views:

22

answers:

1

Hi, is there a way to use request.getRequestDispatcher with a FQDN? Something like

request.getRequestDispatcher("http://mysite.com/test")

If I try it, I get the error

JSPG0036E: Failed to find resource /http:/mysite.com/test

I need to forward it outside the current context to another app.

Thanks

+1  A: 

No, there isn't.

If the another application is running at the same servletcontainer, then best what you can do is to configure the servletcontainer to let those webapps share each other's context so that you can get the other context by ServletContext#getContext() and in turn use its RequestDispatcher.

ServletContext currentContext = getServletContext();
ServletContext otherContext = currentContext.getContext("/test");
otherContext.getRequestDispatcher("/some.jsp").forward(request, response);

If the another application is completely out of your control, then a redirect is best what you can do.

response.sendRedirect("http://mysite.com/test");
BalusC