views:

57

answers:

2

Hi all,

We have a big application having 13 modules. Depending on the customer requirement, we should able to deploy core module+customer specific modules. We are planning to break the app into multiple wars. Now problem is we have some common jsp's like header.jsp, error.jsp etc. Is there any way by which we can keep the common jsp's in core war and rest of the wars will be able to use it or I have to copy these jsp's in the invidiual wars in build process. I know CSS and Javascript files can be shared across multiple wars in ear packaging but not sure about jsp's.

+3  A: 

Good question. You'll be happy to hear that the answer is "yes", although it's highly dependent on how your servlet container is configured.

It's done using the JSTL <c:import> tag, which has an optional context attribute which is defined as:

Name of the context (beginning with a /) of some other local web application to import the resource from.

So say you have webapp A deployed under context root /A, and webapp B deployed under /B, then a JSP in A can include x.jsp from B using:

<c:import context="/B" url="x.jsp"/>

This is all very nice and rosy, but this has to pass through the servlet container's security mechanism, and it may not permit the operation. For example, in Tomcat the crossContext attribute must be set to true.

skaffman
Thanks a lot! It worked perfectly fine..
A: 

Hi user368957,

I too have a similar requirement to share the common static resources like images/css/javascript for multiple WARs.

I have been finding the solutions for this purpose and it would be helpful if you can share how you were able to achieve this task.

I do not have to access JSPs or WEB-INF contents but only static resources like images/css/javascript. May be by maintaining them in EAR content or may be by maintaining in a Utility WAR and then referring this Utility.WAR in other WAR applications?

Regards, Satya

Satya