0

I have a web-app with a lot of lib projects, which are common to another apps. I'd like to put some JSP files in one of those libs and then make a <jsp:include... or <%include... But I'm not able to make it working.

Is there a way to achieve this?

If there is, which is better, to do a include directive (@include file..) or action (<jsp:include page...)?

Thanks

ᄂ ᄀ
  • 5,669
  • 6
  • 43
  • 57
Jorgeblom
  • 3,330
  • 1
  • 23
  • 24
  • What do you mean by 'lib projects' ? – niiraj874u Apr 28 '14 at 15:26
  • possible duplicate of [Can I serve JSPs from inside a JAR in lib, or is there a workaround?](http://stackoverflow.com/questions/5013917/can-i-serve-jsps-from-inside-a-jar-in-lib-or-is-there-a-workaround) – lukelazarovic Apr 28 '14 at 15:26
  • I already read that question and answers but not solving my problem. By "Lib projects" I mean external JAR in the EAR Deployment Assembly. – Jorgeblom Apr 28 '14 at 15:30

1 Answers1

1

I know of only one way.

  1. Keep the JSP in /META-INF/resources folder.
  2. Create a 'lib' folder inside the WEB-INF folder in your WAR.
  3. Place the JAR (containing the JSP in the /META-INF/resources folder) in the lib folder of the WAR.
  4. In the main JSP where you want to include this external JSP residing in the JAR, use the following statement: <jsp:include page="/myJSP.jsp" ></jsp:include>. Note that the '/' is required in front of the jsp file name to make the container look for the JSP in an absolute path (and hence in the jar in the lib folder) rather than in the current path where the main JSP is lying.

This will surely work.

VHS
  • 9,534
  • 3
  • 19
  • 43