Originally posted by Subbu Aswathanarayan:
Hi,
I have a peculiar problem.In my web app there are around 4to 5 jsp pages and i want all these pages to share a common border on the top and left, while the other contents of the page will vary.how can i achive this.i am aware abt the include directive of jsp, but i think it can be used to include only complete html file and not part of the code.to be more precise, i want to include half of the final code from some other page while i want to generate the rest of the code dynamically.
how can i do this?
Subbu
I did something similar to this. If the first file is called "top.jsp" and the second file is called "left.jsp" you can code it like this (or something similar):
<!-- index.jsp file -->
<html>
<head>
<title></title>
</head>
<body>
<table width="100%">
<tr>
<td colspan="2">
<jsp:include page="top.jsp" flush="true" />
</td>
</tr>
<tr>
<td>
<jsp:include page="left.jsp" flush="true" />
</td>
<td>
<%
String filename = request.getParameter("file"); %>
<jsp:include page="<%= filename %>" flush="true" />
</td>
</tr>
</table>
</html>
Of course, this can be modified in any way. In fact, in your "top.jsp" file, you can put everything contained in this file (index.jsp) up until the include action for the top.jsp.
so top.jsp can be:
... some jsp/html code ..
<html>
<head>
<title></title>
</head>
<body>
<table width="100%">
<tr>
<td colspan="2">
------------------
and index.jsp can just be:
<jsp:include page="top.jsp" flush="true">
</td>
</tr>
</table>
... and the rest ...
I hope this helped.