What a JSP contains

A JSP contains static template text that is written to the output stream. It also contains dynamic content that can take several forms:

For more detailed information about using these content types, see “Application logic in JSPs”.

A simple example

This sample JSP contains a directive, a scripting element (in this case an expression), and a standard tag. The dynamic content is shown in bold:

<HTML>
<HEAD><TITLE>Simple JSP</TITLE>
</HEAD>
<BODY>
<P>This page uses three kinds of dynamic content: </P>
<UL><LI>A page directive that imports the java util package.
<%@ page import = "java.util.*" %>
<LI>An expression to get the current date using java.util.Date. Today's date is <%= new Date() %>.
<LI>An include tag to include data from another file without parsing the content. 
<jsp:include page="includedpage.txt" flush="true"/>
</UL>
</BODY>
</HTML>

The page referenced is a text file that contains one sentence and is in the same directory as the JSP file. The included page might also be another resource, such as a JSP file, and its location can be specified using a URI path.

You can call the JSP from an HTML page with a hypertext reference:

<html><body>
<p><a href="simplepage.jsp">Click here to send a request to the simple JSP.</p>
</body></html>

This HTML is returned to the browser:

<HTML>
<HEAD><TITLE>Simple JSP</TITLE>
</HEAD>
<BODY>
<P>This page uses three kinds of dynamic content: </P>
<UL><LI>A page directive that imports the java util package.
<LI>An expression to get the current date using java.util.Date. Today's date is Mon Feb 14 17:03:51 EST 2000.
<LI>An include tag to include data from another file without parsing the content.
In this case the included file is a static file containing this sentence.
</UL>
</BODY>
</HTML>