0

My company has 20+ web applications. They all use Struts2 and Sitemesh to decorate the pages.

Every application has its own version of header.html and footer.html which are included in standard.jsp (using <%@ include file=filename%>).

For look and feel consistency across applications I want to have the header and footer files outside of the web application.

However I can't figure out how to do that!

My decorator.xml looks like this

<decorators defaultdir="/layout">
   <decorator name="standard-layout" page="standard.jsp">
      <pattern>/*</pattern>
   </decorator>
</decorators>

My include directive <%@ include file="/common/header.html%>, gets prefix with the defaultdir value, like this /layout/common/header.html, and I get a file not found error.

The same thing happens if I use an absolute path.

Also, the same thing happens if I change decorators.xml like this.

<decorators>
   <decorator name="standard-layout" page="/layout/standard.jsp">
      <pattern>/*</pattern>
   </decorator>
</decorators>

Help will be appreciated!

Update: I was able to solve this using JSTL

<c:import var="commomHeader" url="/resources/html/common_header.html"/>
${commomHeader} 
tamf
  • 1
  • 1
  • Do you want the header and footer files outside of the web application? Where do you want them? – Roman C Aug 12 '14 at 15:37
  • In a specific directory in the application server. We are already setup to read some configuration files from outside of the application. – tamf Aug 13 '14 at 18:36
  • What are their files? – Roman C Aug 13 '14 at 18:56
  • I don't understand the question. I should clarify that the other configuration files are read from the java classes not from the jsps. The issue that I have is trying to read the footer or header from standard.jsp – tamf Aug 13 '14 at 19:44
  • Did this work for you? My jsp decorator seems to not work like a jsp. It works like html. Instead of including the files like this <%@include file="something.jsp" %> it just prints it and does nothing. How do i import an html in my jsp decorator? – Prateek Jun 13 '18 at 19:03

0 Answers0