File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes JSP referencing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP referencing" Watch "JSP referencing" New topic

JSP referencing

Chad Foor

Joined: Jul 03, 2007
Posts: 23

I have a general question about the <jsp:include> tag.

Here's the situation -
I have 3 applications deployed on a server running under Tomcat 5.5.9.

The first one contains a set of simple JSPs / static content scattered
in various locations around inside its directory structure. (Tomcat is configured to default to point to its top-level welcome file in its server's config.xml.)

The file structure looks like this:

...{Tomcat Install}/webapps/Application_Alpha
...{Tomcat Install}/webapps/Application_Beta
...{Tomcat Install}/webapps/Application_Gamma

Here's what I'd like to do: Alpha contains all the common look/feel files that enforce a standard I'm trying to impose on all the pages for this server machine. (That is, common JSPs, Cascading Style Sheets, Images, etc. )

For applications Beta and Gamma, what I'd like to do in their JSP pages is
reference the JSPs located under Alpha like so,

index.jsp (under Application_Beta/Gamma) welcome page:

...(xhtml declarations)...

<jsp:include page="http://this.example.server/Application_Alpha/resources/header.jsp">


... (whatever)


The question I have is - is this possible ? and if so, how would I go about doing this ?? I've had some success referencing locations such as .css files and .gifs, but so far, have yet to be successful getting .jsp files to work.

I appreciate your help.

Thank you,
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

The jsp:include action does not work for pages outside of the current context.

This can be done with JSTL.
Read up on <c:import .../>

Unless you have a real good reason for breaking your app up into mutiple contexts, I would avoid doing so.
A lot of people run into problems when they do this.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Chad Foor

Joined: Jul 03, 2007
Posts: 23
Thank you !

That worked quite well.

I agree. Here's the link:
subject: JSP referencing
It's not a secret anymore!