I want to create a web app in which every page on the site has a standard
header along the top and a standard menu along the left edge (a pretty
standard thing).

I came up with 2 ways of doing this:

1. Use a table tag and jsp:include tags on EVERY page:

<table>
  <tr>
    <td><jsp:include page="standardHeader.jsp"/></td>
  </tr>
  <tr>
    <td colspan="2">
    <table>
      <tr>
        <td valign="top"><jsp:include page="/menu.jsp" /></td>
        <td valign="top">
         THIS IS WHERE THE PAGE-SPECIFIC CONTENT (i.e. the body)*
        </td>
      </tr>
    </table>
    </td>
  </tr>
</table>

2. Invert the above solution to create one master template (or controller)
and have the content page name passed in as a parameter. Here would be the
master template-controller page:

<table>
  <tr>
    <td><jsp:include page="standardHeader.jsp"/></td>
  </tr>
  <tr>
    <td colspan="2">
    <table>
      <tr>
        <td valign="top"><jsp:include page="/menu.jsp" /></td>
        <td valign="top">
         <jsp:include page="<%=request.getParameter("contentPage")%>" />*
        </td>
      </tr>
    </table>
    </td>
  </tr>
</table>

The key difference between these two architectures are best understood by
looking at the 2 lines with the * at the end. Also, in option 2, there is
only one copy of the above code. In option 1, there is one copy "per content
page"

Q1: Does anyone have any preference between options 1 and 2?
Q2: Is there a better way of achieving this result?
Q3: Do either have any negetive drawback I need to consider? (I will be
converting an entire site)

By the way, I'm currently achieving this effect VERY easily using good old
client-side html frames. But due to popular demand, framse must go.

Dave Ford
Smart Soft - The Java Training Company
http://www.smart-soft.com


Reply via email to