Skip to Main Content
Java Cookbook
book

Java Cookbook

by Ian F. Darwin
June 2001
Intermediate to advanced content levelIntermediate to advanced
888 pages
21h 1m
English
O'Reilly Media, Inc.
Content preview from Java Cookbook

JSP Syntax Summary

Problem

You can’t remember all this post-HTML syntax.

Solution

Use the Table.

Discussion

Table 18-1 summarizes the syntax of JavaServer Pages. As the title implies, it contains only the basics; a more complete syntax can be downloaded from http://java.sun.com/products/jsp/.

Table 18-1. Basic JSP Syntax

Item

Syntax

Example

Scriptlet

<% code;%>
<% mountain.setHeight(1000); %>

Expression (to print)

<%= expr %>
<%= mountain.getHeight(  ) %>

Declaration

<%! decls; %>
<%! int height = 0; %>

Include

<jsp:include page="URL" flush=true />
<jsp:include page="./mountain-list.html" flush=true />

Forward

<jsp:forward page="url"/>
<jsp:forward page="./last-resort.html"/>

Use bean

<jsp:useBean .../>
<jsp:useBean class="x.ClimbBean" id="myClimbBean" scope="page"/>

Set property

<jsp:setProperty ... />
<jsp:setProperty name="myClimbBean" property="*" />

Page directive

<%@ page ... %>
<%@ page import="java.io.*" errorPage="catcher.jsp" %>

Comment

<!-- comment -->
<%!-- This comment appears in HTML -->

Hidden comment

<%-- comment --%>
<%-- This comment is local to JSP --%>
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Practical Cloud-Native Java Development with MicroProfile

Practical Cloud-Native Java Development with MicroProfile

Emily Jiang, Andrew McCright, John Alcorn, David Chan, Alasdair Nottingham
Distributed Computing in Java 9

Distributed Computing in Java 9

Raja Malleswara Rao Malleswara Rao Pattamsetti

Publisher Resources

ISBN: 0596001703Supplemental ContentCatalog PageErrata