开发者

sharing common jsp's in multiple wars in an EAR

开发者 https://www.devze.com 2023-01-17 10:00 出处:网络
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.

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 et开发者_高级运维c. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号