Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a master page?

Tags:

jsp

templating

I need to create a master page in JSP to be used by other JSPs for them to have the same look and feel and menus. How can I do that in JSP?

like image 926
Ianthe Avatar asked Dec 16 '22 08:12

Ianthe


2 Answers

You can use either

<%@ include file="/absoluteFragment.jsp" %>

or

<jsp:include page="relativeDynFragment.jsp" />

To know the difference see also http://www.jguru.com/faq/view.jsp?EID=13517:

The <%@include file="abc.jsp"%> directive acts like C "#include", pulling in the text of the included file and compiling it as if it were part of the including file. The included file can be any type (including HTML or text).

The <jsp:include page="abc.jsp"> tag compiles the file as a separate JSP file, and embeds a call to it in the compiled JSP.

like image 56
vikas27 Avatar answered Jan 27 '23 14:01

vikas27


You can use <jsp:include /> tag or JSP Templates. In case if you are familiar with JSF (JavaServer Faces technology) then use Facelets.

like image 34
KV Prajapati Avatar answered Jan 27 '23 14:01

KV Prajapati