ADS

Using Jsp Include Xml Tag

The following example illustrates <jsp:include> tag which is used to transfer the current request and response objects to a new jsp page and include that result in this page. It is not an alternative to @include directive
    This is a pre-defined tag, hence the prefix jsp and doesn't need to load external tag libraries. Those who are familiar with tags will find this comfortable. This contains mandatory page attribute. Let us look at its syntax. This tag is used to embed other pages into a JSP page and you can write as many tags you want.
<jsp:include page="sample.html"/>

Folder structure
webapps
           |_ jsp4
                   |_ index.jsp
                   |_ sample.html

index.jsp

 
<html>
    <body>
    This is in the html body<br/>
    <jsp:include page="sample.html"/>
    </body>
</html>

sample.html

 
<html>
    <body>
    <h2>This is a h2 heading</h2>
    <p>This is a paragraph in sample.html</p>
    </body>
</html>

Previous: Using JSP Scriptlet XML Tag and Next: Using JSP forward tag

Subscribe to receive free email updates:

ADS