JSP Includes
It is possible -- and sometimes greatly desirable -- to nest JSPs.
There are two principle ways to do this:
Option 1: Directly include a file within another
<%@ include file="path/to/file.jsp" %>
Anything contained in this path is slapped directly in the HTML. This is useful if you have a lot of static elements repeated several times.
Option 2: Use a JSP include and pass in parameters
<jsp:include page="dogs.jsp" >
<jsp:param name="dogName" value="${dogName}" />
<jsp:param name="dogBreed" value="${dogBreed}" />
</jsp:include>
In this option, you can include a JSP file and pass in parameters. This is powerful if you have code that is very similar except for a few different values being passed through.
You can access the parameters within dogs.jsp by using ${param.dogName} and ${param.dogBreed}.