Appendix D Code Snippets
========================
p. 748, bottom of page
<%
int salAmount = 3000;
if (salAmount > 0) {
%>
The salary is positive.
<%
}
else {
%>
| Warning! |
Salary is negative or zero.
Contact your Financial Advisor.
|
<%
}
%>
--------------------------
p. 751, Scripting Elements in the Servlet
<%-- scriptlets --%>
<%
int salAmount = 3000;
if (salAmount > 0) {
%>
The salary is positive.
<%
out.write("The new salary is " + calcRaise(salAmount));
%>
<%
}
else {
%>
The salary is
<%-- expression --%>
<%= salAmount %>
<%
}
%>
<%// expression %>
<%= "Salary is " + salAmount %>
%-- declaration --%>
<%!
public static double calcRaise(int salary) {
return(salary * 1.3);
}
%>
--------------------------
p. 759, JSP Standard Tag Library
<% for (int i = 1; i <= 3; i++) { %>
<% for (int j = 1; j <= 4; j++) { %>
|
<%= i %>:<%= j %>
|
<%} %>
<% } %>
--------------------------
p. 760, JSTL Example
--------------------------
p. 766, The Sample Code
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
Build a Table
Both Rows and Columns must be greater than 0.
Table Dimensions
--------------------------