How do I include a page fragment into JSP?

Category: jsp.snippets, viewed: 3215 time(s).

In this example you can learn how to include a JSP fragment into another JSP page. This is a common practice when creating a web application where we usually have a navigation section, the main content and the footer of a web page.

Using the include directive make it simpler to maintain the fragment of a web page, which mean that when we need to change the footer section we just need to alter the footer include file and all the page that includes it will get the benefit.

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Webapp Include Demo</title>
</head>
<body>

<div id="header">
    <%@ include file="/common/header.jspf" %>
</div>

<div id="content">
    <p>Main application content goes here!</p>    
</div>

<div id="footer">
    <%@ include file="/common/footer.jspf" %>
</div>

</body>
</html>
Click here to lend your support to: Kode Java Org and make a donation at www.pledgie.com !

 

Uncensored Newsgroups
Download Hundreds of Complimentary Industry Resources

Get hundreds of popular Industry magazines, white papers, webinars, podcasts, and more; all available at no cost to you. With more than 600 complimentary offers, you'll find plenty of titles to suit your professional interests and needs. Click Here and Sign up today!

Java Training

Sponsored Links

Our Friends

Statistics

Locations of visitors to this page
visitor stats