| JSP Directives |
| |
| Example Using Scripting Elements and Directives |
| |
| Here is a simple example showing the use of JSP expressions, scriptlets, declarations, and directives: |
| |
<HTML>
<HEAD>
<TITLE>Learning and Using JavaServer Pages</TITLE>
<META NAME="author" CONTENT="eBIZ Tutorial Developer Team">
<META NAME="keywords"
CONTENT="JSP,JavaServer Pages,servlets">
<META NAME="description"
CONTENT="A quick example of the four main JSP tags.">
<LINK REL=STYLESHEET
HREF="My-Style-Sheet.css"
TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FDF006" TEXT="#123450" LINK="#0000EE"
VLINK="#551A8B" ALINK="#FF0000">
<CENTER>
<TABLE BORDER=5 BGCOLOR="#008429">
<TR><TH CLASS="TITLE">
Using JavaServer Pages</TABLE>
</CENTER>
<P>ebiz show you some dynamic content created using various JSP mechanisms:</p>
<UL>
<LI><B>Expression.</B>
<BR>
Your hostname: <%= request.getRemoteHost() %>.
<LI><B>Scriptlet.</B>
<BR>
<% out.println("Attached GET data: " +
request.getQueryString()); %>
<LI><B>Declaration (plus expression).</B>
<BR>
<%! private int accessCount = 0; %>
Accesses to page since server reboot: <%= ++accessCount %>
<LI><B>Directive (plus expression).</B>
<BR>
<%@ page import = "java.util.*" %>
Current date: <%= new Date() %>
</UL>
</BODY>
</HTML> |
| |
| Here's a typical result: |
|
|
| |
| |
|
| |
| |