How can I put absolute URL in my jsp:include ? I�m trying to make a include from another web application, but it always resolves with the current context. <jsp:include page="/rightcontext/page.jsp" flush="true" /> /mycontext/rightcontext/page.jsp
You're right, include and forward will always resolve to the current application context. All is not lost, since there are ways to communicate between contexts. The problem is that it is highly vendor specific and if you really want to do this you're going to have problems. It goes like this: A RequestDispatcher can load (ie include of forward to) a JSP, but a RequestDispatcher is specific to a ServletContext. From a Servlet, you can get the ServletContext, from a ServletContext you can get a handle to another (named) ServletContext. From this ServletContext, you can a RequestDispatcher to load the resource. That's it in theory, as to how it actually works in the server you are using, who knows. I'd still recommend a sendRedirect to the resource in that context. (Problems you'll possibly run into: the named context may or may not require a leading slash, since the RequestDispatcher may exist on the other sde of the Thread pool its possible the include could happen just about anywhere in the output. Good luck ) Dave
Josiel Oliveira
Greenhorn
Joined: Nov 13, 2001
Posts: 17
posted
0
David, thanks for answering. I�m using, in my servlets, the code below to forward to a different context. this.getServletContext().getContext("/ApacAdmin").getRequestDispatcher("/any_stuff.jsp").forward(request, response); It seems to work in Tomcat 3.2.3 and 4.0.1 The problem is still the include tags in pages. I shall keep trying. Thanks!
Originally posted by Josiel Oliveira: David, thanks for answering. I�m using, in my servlets, the code below to forward to a different context. this.getServletContext().getContext("/ApacAdmin").getRequestDispatcher("/any_stuff.jsp").forward(request, response); It seems to work in Tomcat 3.2.3 and 4.0.1 The problem is still the include tags in pages. I shall keep trying. Thanks!
JSTL's standard <c:import> tag lets you perform cross-context imports (and, separately, imports via absolute URLs). For more JSTL (JSP Standard Tag Library) info, see http://java.sun.com/products/jsp/jstl
Shawn Bayern<br />"JSTL in Action" <a href="http://www.jstlbook.com" target="_blank" rel="nofollow">http://www.jstlbook.com</a>