Skip to main content

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
           |_ jsp4
                   |_ index.jsp
                   |_ sample.html


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


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

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


Popular posts from this blog

Setting Background Image in JFrame - Swing

Here is sample tutorial, a simple trick that enables you to set background image for JFrame.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class BackgroundImageJFrame extends JFrame
JButton b1;
JLabel l1;
public BackgroundImageJFrame()
setTitle("Background Color for JFrame");
One way
setLayout(new BorderLayout());
JLabel background=new JLabel(new ImageIcon("C:\\Users\\Computer\\Downloads\\colorful design.png"));
background.setLayout(new FlowLayout());
l1=new JLabel("Here is a button");
b1=new JButton("I am a button");
// Another way
setLayout(new BorderLayout());
setContentPane(new JLabel(new ImageIcon("C:\\Users\\Computer\\Downloads\\colorful design.png")));
setLayout(new FlowLayout());
l1=new JLabel("Here is a button");
b1=new JButton("I am …

Add two numbers in JSP easily

Here is an example on adding up two numbers in JSP. This is very simple as you see below. This requires very small piece of code. All i have done here is created a HTML file containing the input fields which contain the numbers to add up.Now the values in the input field are of type String, so i have done type casting and converted them into int using Integer.parseInt(). See how easy it looks.

Catch The Rat: Simple Game in Java

A simple, shortest and easiest game that could be written in Java using Swing components and event handling.