문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top