• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Absolute URL in jsp:include

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

Thanks for any advice
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Author
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic