O'Reilly logo

Head First Servlets and JSP, 2nd Edition by Bert Bates, Bryan Basham, Kathy Sierra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The include directive

The include directive tells the Container one thing: copy everything in the included file and paste it into this file, right here...

Standard header file (“Header.jsp”)

<html><body>

<img src="images/Web-Services.jpg" > <br>
<em><strong>We know how to make SOAP suck less.</strong></em> <br>

</body></html>

Note

We want this HTML content on every page in our web app.

image with no caption

A JSP from the web app (“Contact.jsp”)

<html><body>

<%@ include file="Header.jsp"%>

<br>
<em>We can help.</em> <br><br>
Contact us at: ${initParam.mainEmail}
</body></html>

Note

This says “Insert the complete Header.jsp file into this point in THIS page, then keep going with the rest of this JSP...”

image with no caption

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required