Programmatic out-of-context includes in JSP (for shared code)
Posted on 2003-03-05
I want to be able to share global resources across web sites. For example, foo.jsp which performs xyz, needs to be able to be included in jsp from several sites which use foo.jsp. Copying the global resources N times is NOT an option for obvious reasons.
I know about:
and I've read about:
ServletContext testContext = getServletContext();
RequestDispatcher disp = testContext.getRequestDispatcher( "/foofiles/foo.jsp" );
disp.include( request, response );
but it seems that the included resources have to PHYSICALLY reside WITHIN the context of the application you're running.
I've even tried doing the above Java code from within <% jsp %> tags however this produced no output and I don't think the context was being found. Either that or the found JSP was not being processed and output. Do included resources create their own output streams???
I've experimented with <context> tags in Tomcat, but to no avail. Does anyone know how I can include (programmitically using passed or read-in data) files from a cross-context resource. If this is a limitation of JSP, I consider it a SEVERE limitation. Doing this is ASP or JHTML on ATG Dynamo is easy and simple -- just create a virtual directory pointing TO anywhere and access it FROM anywhere. JSP/J2EE seems to make this a burden (or impossible?!?).
Thanks for your responses and solutions.