How do I include a JSP file from a different project into my project

This works only if the other project is bundled in flavor of a JAR file in /WEB-INF/lib folder of the main webapp project and if the JSP file is in turn placed in /META-INF/resources folder of the other project.

So, if you have a /META-INF/resources/common/webappfooter.jsp in the other project, then the following include should do:

<jsp:include path="/common/webappfooter.jsp" />

If you’re using a bit self-respected IDE, you can configure it to automatically bundle the other project as JAR of webapp project’s /WEB-INF/lib. It’s unclear what IDE you’re using, but in Eclipse it’s a matter of adding the other project as Deployment Assembly in the main webapp project’s properties.

alt text

In Eclipse, to create such a project with the right folder structure prepared, choose the “Web Fragment Project” wizard.

Leave a Comment