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 --%> |
Get Java Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.