I have 2 jsp pages HeaderTemplate.Jsp and mainMenu.jsp.In header Template.jsp i have one table inside body of html and in mainMenu before body I have to include that table content How i will do that please help me
2 Answers
You can use the below tag to include your jsp
<jsp:include page="..." />

- 8,113
- 3
- 31
- 61
-
My HeaderTemplate.jsp is
-
Please edit your Question. Dont try to write this in comment. Thank you. – A Paul Dec 16 '13 at 07:43
there are different ways you can include jsps
1) <%@ include file=”filename” %>
is jsp directive syntax (static include).
Then the source JSP page is converted into a java servlet class. The included file can be a static resource or a JSP page. Generally JSP include directive is used to include header banners and footers.
The JSP compilation procedure is that, the source JSP page gets compiled only if that page has changed. If there is a change in the included JSP file, the source JSP file will not be compiled and therefore the modification will not get reflected in the output.
2) <jsp:include page=”relativeURL” />
is a dynamic include, since you want to include jsp, you need to use <jsp:include>
, since it works with dynamic content
The jsp:include action element is like a function call. At runtime, the included file will be ‘executed’ and the result content will be included with the soure JSP page. When the included JSP page is called, both the request and response objects are passed as parameters
3) you can use templates framework like tiles, freemaker etc. which manages your templates and include jsps defined in your custom template.
for more about tiles
http://tiles.apache.org/framework/tutorial/
if you have many jsps and one or more layout design then template frameworks will be more flexible

- 2,378
- 8
- 49
- 93