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 application.
Thanks
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");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.