Duke Says Hello
The Duke Banner (dukebanner.html)
<table border="0" width="400" cellspacing="0" cellpadding="0"> <tr> <td height="150" width="150"> </td> <td width="250"> </td> </tr> <tr> <td width="150"> </td> <td align="right" width="250"> <img src="duke.waving.gif"> </td> </tr> </table> <br>
The JSP Page (helloworld.jsp)
<%@ page info="a hello world example" %> <html> <head><title>Hello, World</title></head> <body bgcolor="#ffffff" background="background.gif"> <%@ include file="dukebanner.html" %> <table> <tr> <td width=150> </td> <td width=250 align=right> <h1>Hello, World!</h1> </td> </tr> </table> </body> </html>
The Page Directive<%@ page info="a hello world example" %>
The page directive gives instructions to the JSP engine that apply to the entire JSP source file. In this example, page specifies an informative comment that will become part of the compiled JSP file. In other cases, page might specify the scripting language used in the JSP source file, packages the source file would import, or the error page called if an error or exception occurs.
The Include Directive
The include directive inserts the contents of another file in the main JSP file, where the directive is located. It's useful for including copyright information, scripting language files, or anything you might want to reuse in other applications. In this example, the included file is an HTML table that creates a graphic banner.
You can see the content of the included file by viewing the page source of the main JSP file while you are running Hello, World. The included file does not contain <html> or <body> tags, because these tags would conflict with the same tags in the calling JSP file.
A Note About the JSP Tags
As you use the examples in this chapter, remember that the JSP tags are case sensitive. If, for example, you type <jsp:usebean> instead of <jsp:useBean>, your tag will not be recognized, and the JSP 1.0 reference implementation will throw an exception. Some of the attributes on the tags take class names, package names, pathnames or other case-sensitive values as well.
How To Run the Example
[Top] [Prev] [Next] [Bottom]
Copyright © 1999, Sun Microsystems, Inc. All rights reserved.
Oracle is reviewing the Sun product roadmap and will provide guidance to customers in accordance with Oracle's standard product communication policies. Any resulting features and timing of release of such features as determined by Oracle's review of roadmaps, are at the sole discretion of Oracle. All product roadmap information, whether communicated by Sun Microsystems or by Oracle, does not represent a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. It is intended for information purposes only, and may not be incorporated into any contract.
© 2010, Oracle Corporation and/or its affiliates