blob: c6b1c43568736470ea5fc7d614d2923d545f9640 [file] [log] [blame]
Hongqing Liufd5ee812014-05-10 16:32:51 +08001<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
2<html>
3<!--
4 Licensed to the Apache Software Foundation (ASF) under one or more
5 contributor license agreements. See the NOTICE file distributed with
6 this work for additional information regarding copyright ownership.
7 The ASF licenses this file to You under the Apache License, Version 2.0
8 (the "License"); you may not use this file except in compliance with
9 the License. You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18-->
19<head>
20 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
21 <meta name="GENERATOR" content="Mozilla/4.61 [en] (WinNT; I) [Netscape]">
22 <meta name="Author" content="Anil K. Vijendran">
23 <title>JSP Examples</title>
24</head>
25<body bgcolor="#FFFFFF">
26<b><font face="Arial, Helvetica, sans-serif"><font size=+2>JSP
27Samples</font></font></b>
28<p>This is a collection of samples demonstrating the usage of different
29parts of the Java Server Pages (JSP) specification. Both JSP 2.0 and
30JSP 1.2 examples are presented below.
31<p>These examples will only work when these pages are being served by a
32servlet engine; of course, we recommend
33<a href="http://tomcat.apache.org/">Tomcat</a>.
34They will not work if you are viewing these pages via a
35"file://..." URL.
36<p>To navigate your way through the examples, the following icons will
37help:
38<br>&nbsp;
39<table BORDER=0 CELLSPACING=5 WIDTH="85%" >
40<tr VALIGN=TOP>
41<td WIDTH="30"><img SRC="images/execute.gif" ></td>
42
43<td>Execute the example</td>
44</tr>
45
46<tr VALIGN=TOP>
47<td WIDTH="30"><img SRC="images/code.gif" height=24 width=24></td>
48
49<td>Look at the source code for the example</td>
50</tr>
51
52<!--<tr VALIGN=TOP>
53<td WIDTH="30"><img SRC="images/read.gif" height=24 width=24></td>
54
55<td>Read more about this feature</td>
56-->
57
58</tr>
59<tr VALIGN=TOP>
60<td WIDTH="30"><img SRC="images/return.gif" height=24 width=24></td>
61
62<td>Return to this screen</td>
63</tr>
64</table>
65
66<p>Tip: For session scoped beans to work, the cookies must be enabled.
67This can be done using browser options.
68<br>&nbsp;
69<br>
70<b><u><font size="+1">JSP 2.0 Examples</font></u></b><br>
71
72<table BORDER=0 CELLSPACING=5 WIDTH="85%" >
73<tr valign=TOP>
74<td><b>Expression Language</b></td>
75</tr>
76
77<tr valign=TOP>
78<td>Basic Arithmetic</td>
79<td valign=TOP width="30%"><a href="jsp2/el/basic-arithmetic.jsp"><img src="images/execute.gif" hspace=4 border=0 align=top></a><a href="jsp2/el/basic-arithmetic.jsp">Execute</a></td>
80
81<td width="30%"><a href="jsp2/el/basic-arithmetic.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="jsp2/el/basic-arithmetic.html">Source</a></td>
82</tr>
83
84<tr valign=TOP>
85<td>Basic Comparisons</td>
86<td valign=TOP width="30%"><a href="jsp2/el/basic-comparisons.jsp"><img src="images/execute.gif" hspace=4 border=0 align=top></a><a href="jsp2/el/basic-comparisons.jsp">Execute</a></td>
87
88<td width="30%"><a href="jsp2/el/basic-comparisons.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="jsp2/el/basic-comparisons.html">Source</a></td>
89</tr>
90
91<tr valign=TOP>
92<td>Implicit Objects</td>
93<td valign=TOP width="30%"><a href="jsp2/el/implicit-objects.jsp?foo=bar"><img src="images/execute.gif" hspace=4 border=0 align=top></a><a href="jsp2/el/implicit-objects.jsp?foo=bar">Execute</a></td>
94
95<td width="30%"><a href="jsp2/el/implicit-objects.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="jsp2/el/implicit-objects.html">Source</a></td>
96</tr>
97<tr valign=TOP>
98
99<td>Functions</td>
100<td valign=TOP width="30%"><a href="jsp2/el/functions.jsp?foo=JSP+2.0"><img src="images/execute.gif" hspace=4 border=0 align=top></a><a href="jsp2/el/functions.jsp?foo=JSP+2.0">Execute</a></td>
101
102<td width="30%"><a href="jsp2/el/functions.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="jsp2/el/functions.html">Source</a></td>
103</tr>
104
105<tr valign=TOP>
刘洪青6266f992017-05-15 21:21:03 +0800106<td>Composite Expressions</td>
107<td valign=TOP width="30%"><a href="jsp2/el/composite.jsp"><img src="images/execute.gif" hspace=4 border=0 align=top></a><a href="jsp2/el/composite.jsp">Execute</a></td>
108
109<td width="30%"><a href="jsp2/el/composite.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="jsp2/el/composite.html">Source</a></td>
110</tr>
111
112
113<tr valign=TOP>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800114<td><br><b>SimpleTag Handlers and JSP Fragments</b></td>
115</tr>
116
117<tr valign=TOP>
118<td>Hello World Tag</td>
119<td valign=TOP width="30%"><a href="jsp2/simpletag/hello.jsp"><img src="images/execute.gif" hspace=4 border=0 align=top></a><a href="jsp2/simpletag/hello.jsp">Execute</a></td>
120
121<td width="30%"><a href="jsp2/simpletag/hello.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="jsp2/simpletag/hello.html">Source</a></td>
122</tr>
123
124<tr valign=TOP>
125<td>Repeat Tag</td>
126<td valign=TOP width="30%"><a href="jsp2/simpletag/repeat.jsp"><img src="images/execute.gif" hspace=4 border=0 align=top></a><a href="jsp2/simpletag/repeat.jsp">Execute</a></td>
127
128<td width="30%"><a href="jsp2/simpletag/repeat.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="jsp2/simpletag/repeat.html">Source</a></td>
129</tr>
130
131<tr valign=TOP>
132<td>Book Example</td>
133<td valign=TOP width="30%"><a href="jsp2/simpletag/book.jsp"><img src="images/execute.gif" hspace=4 border=0 align=top></a><a href="jsp2/simpletag/book.jsp">Execute</a></td>
134
135<td width="30%"><a href="jsp2/simpletag/book.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="jsp2/simpletag/book.html">Source</a></td>
136</tr>
137
138<tr valign=TOP>
139<td><br><b>Tag Files</b></td>
140</tr>
141
142<tr valign=TOP>
143<td>Hello World Tag File</td>
144<td valign=TOP width="30%"><a href="jsp2/tagfiles/hello.jsp"><img src="images/execute.gif" hspace=4 border=0 align=top></a><a href="jsp2/tagfiles/hello.jsp">Execute</a></td>
145
146<td width="30%"><a href="jsp2/tagfiles/hello.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="jsp2/tagfiles/hello.html">Source</a></td>
147</tr>
148
149<tr valign=TOP>
150<td>Panel Tag File</td>
151<td valign=TOP width="30%"><a href="jsp2/tagfiles/panel.jsp"><img src="images/execute.gif" hspace=4 border=0 align=top></a><a href="jsp2/tagfiles/panel.jsp">Execute</a></td>
152
153<td width="30%"><a href="jsp2/tagfiles/panel.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="jsp2/tagfiles/panel.html">Source</a></td>
154</tr>
155
156<tr valign=TOP>
157<td>Display Products Example</td>
158<td valign=TOP width="30%"><a href="jsp2/tagfiles/products.jsp"><img src="images/execute.gif" hspace=4 border=0 align=top></a><a href="jsp2/tagfiles/products.jsp">Execute</a></td>
159
160<td width="30%"><a href="jsp2/tagfiles/products.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="jsp2/tagfiles/products.html">Source</a></td>
161</tr>
162
163<tr valign=TOP>
164<td><br><b>New JSP XML Syntax (.jspx)</b></td>
165</tr>
166
167<tr valign=TOP>
168<td>XHTML Basic Example</td>
169<td valign=TOP width="30%"><a href="jsp2/jspx/basic.jspx"><img src="images/execute.gif" hspace=4 border=0 align=top></a><a href="jsp2/jspx/basic.jspx">Execute</a></td>
170
171<td width="30%"><a href="jsp2/jspx/basic.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="jsp2/jspx/basic.html">Source</a></td>
172</tr>
173
174<tr valign=TOP>
175<td>SVG (Scalable Vector Graphics)</td>
176<td valign=TOP width="30%"><a href="jsp2/jspx/svgexample.html"><img src="images/execute.gif" hspace=4 border=0 align=top></a><a href="jsp2/jspx/svgexample.html">Execute</a></td>
177
178<td width="30%"><a href="jsp2/jspx/textRotate.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="jsp2/jspx/textRotate.html">Source</a></td>
179</tr>
180
181<tr valign=TOP>
182<td><br><b>Other JSP 2.0 Features</b></td>
183</tr>
184
185<tr valign=TOP>
186<td>&lt;jsp:attribute&gt; and &lt;jsp:body&gt;</td>
187<td valign=TOP width="30%"><a href="jsp2/jspattribute/jspattribute.jsp"><img src="images/execute.gif" hspace=4 border=0 align=top></a><a href="jsp2/jspattribute/jspattribute.jsp">Execute</a></td>
188
189<td width="30%"><a href="jsp2/jspattribute/jspattribute.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="jsp2/jspattribute/jspattribute.html">Source</a></td>
190</tr>
191
192<tr valign=TOP>
193<td>Shuffle Example</td>
194<td valign=TOP width="30%"><a href="jsp2/jspattribute/shuffle.jsp"><img src="images/execute.gif" hspace=4 border=0 align=top></a><a href="jsp2/jspattribute/shuffle.jsp">Execute</a></td>
195
196<td width="30%"><a href="jsp2/jspattribute/shuffle.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="jsp2/jspattribute/shuffle.html">Source</a></td>
197</tr>
198
199<tr valign=TOP>
200<td>Attributes With Dynamic Names</td>
201<td valign=TOP width="30%"><a href="jsp2/misc/dynamicattrs.jsp"><img src="images/execute.gif" hspace=4 border=0 align=top></a><a href="jsp2/misc/dynamicattrs.jsp">Execute</a></td>
202
203<td width="30%"><a href="jsp2/misc/dynamicattrs.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="jsp2/misc/dynamicattrs.html">Source</a></td>
204</tr>
205
206<tr valign=TOP>
207<td>JSP Configuration</td>
208<td valign=TOP width="30%"><a href="jsp2/misc/config.jsp"><img src="images/execute.gif" hspace=4 border=0 align=top></a><a href="jsp2/misc/config.jsp">Execute</a></td>
209
210<td width="30%"><a href="jsp2/misc/config.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="jsp2/misc/config.html">Source</a></td>
211</tr>
212
213</table>
214
215<br>
216<b><u><font size="+1">JSP 1.2 Examples</font></u></b><br>
217<table BORDER=0 CELLSPACING=5 WIDTH="85%" >
218<tr VALIGN=TOP>
219<td>Numberguess&nbsp;</td>
220
221<td VALIGN=TOP WIDTH="30%"><a href="num/numguess.jsp"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP></a><a href="num/numguess.jsp">Execute</a></td>
222
223<td WIDTH="30%"><a href="num/numguess.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="num/numguess.html">Source</a></td>
224</tr>
225
226<tr VALIGN=TOP>
227<td>Date&nbsp;</td>
228
229<td VALIGN=TOP WIDTH="30%"><a href="dates/date.jsp"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP></a><a href="dates/date.jsp">Execute</a></td>
230
231<td WIDTH="30%"><a href="dates/date.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="dates/date.html">Source</a></td>
232</tr>
233
234<tr VALIGN=TOP>
235<td>Snoop</td>
236
237<td WIDTH="30%"><a href="snp/snoop.jsp"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP></a><a href="snp/snoop.jsp">Execute</a></td>
238
239<td WIDTH="30%"><a href="snp/snoop.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="snp/snoop.html">Source</a></td>
240</tr>
241
242<tr VALIGN=TOP>
243<td>ErrorPage&nbsp;</td>
244
245<td WIDTH="30%"><a href="error/error.html"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP></a><a href="error/error.html">Execute</a></td>
246
247<td WIDTH="30%"><a href="error/er.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="error/er.html">Source</a></td>
248</tr>
249
250<tr VALIGN=TOP>
251<td>Carts&nbsp;</td>
252
253<td VALIGN=TOP WIDTH="30%"><a href="sessions/carts.html"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP></a><a href="sessions/carts.html">Execute</a></td>
254
255<td WIDTH="30%"><a href="sessions/crt.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="sessions/crt.html">Source</a></td>
256</tr>
257
258<tr VALIGN=TOP>
259<td>Checkbox&nbsp;</td>
260
261<td VALIGN=TOP WIDTH="30%"><a href="checkbox/check.html"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP></a><a href="checkbox/check.html">Execute</a></td>
262
263<td WIDTH="30%"><a href="checkbox/cresult.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="checkbox/cresult.html">Source</a></td>
264</tr>
265
266<tr VALIGN=TOP>
267<td>Color&nbsp;</td>
268
269<td VALIGN=TOP WIDTH="30%"><a href="colors/colors.html"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP></a><a href="colors/colors.html">Execute</a></td>
270
271<td WIDTH="30%"><a href="colors/clr.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="colors/clr.html">Source</a></td>
272</tr>
273
274<tr VALIGN=TOP>
275<td>Calendar&nbsp;</td>
276
277<td WIDTH="30%"><a href="cal/login.html"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP></a><a href="cal/login.html">Execute</a></td>
278
279<td WIDTH="30%"><a href="cal/calendar.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="cal/calendar.html">Source</a></td>
280</tr>
281
282<tr VALIGN=TOP>
283<td>Include&nbsp;</td>
284
285<td VALIGN=TOP WIDTH="30%"><a href="include/include.jsp"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP></a><a href="include/include.jsp">Execute</a></td>
286
287<td WIDTH="30%"><a href="include/inc.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="include/inc.html">Source</a></td>
288</tr>
289
290<tr VALIGN=TOP>
291<td>Forward&nbsp;</td>
292
293<td VALIGN=TOP WIDTH="30%"><a href="forward/forward.jsp"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP></a><a href="forward/forward.jsp">Execute</a></td>
294
295<td WIDTH="30%"><a href="forward/fwd.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="forward/fwd.html">Source</a></td>
296</tr>
297
298<tr VALIGN=TOP>
299<td>Plugin&nbsp;</td>
300
301<td VALIGN=TOP WIDTH="30%"><a href="plugin/plugin.jsp"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP></a><a href="plugin/plugin.jsp">Execute</a></td>
302
303<td WIDTH="30%"><a href="plugin/plugin.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="plugin/plugin.html">Source</a></td>
304</tr>
305
306<tr VALIGN=TOP>
307<td>JSP-Servlet-JSP&nbsp;</td>
308
309<td VALIGN=TOP WIDTH="30%"><a href="jsptoserv/jsptoservlet.jsp"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP></a><a href="jsptoserv/jsptoservlet.jsp">Execute</a></td>
310
311<td WIDTH="30%"><a href="jsptoserv/jts.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="jsptoserv/jts.html">Source</a></td>
312</tr>
313
314<tr VALIGN=TOP>
315<td>Custom tag example</td>
316
317<td VALIGN=TOP WIDTH="30%"><a href="simpletag/foo.jsp"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP></a><a href="simpletag/foo.jsp">Execute</a></td>
318
319<td WIDTH="30%"><a href="simpletag/foo.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="simpletag/foo.html">Source</a></td>
320</tr>
321
322<tr valign=TOP>
323<td>XML syntax example</td>
324<td valign=TOP width="30%"><a href="xml/xml.jsp"><img src="images/execute.gif" hspace=4 border=0 align=top></a><a href="xml/xml.jsp">Execute</a></td>
325
326<td width="30%"><a href="xml/xml.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="xml/xml.html">Source</a></td>
327</tr>
328
329</table>
330
331<br/>
332<b><u><font size="+1">Tag Plugins</font></u></b><br>
333<table BORDER=0 CELLSPACING=5 WIDTH="85%" >
334
335<tr VALIGN=TOP>
336 <td>If&nbsp;</td>
337 <td VALIGN=TOP WIDTH="30%">
刘洪青6266f992017-05-15 21:21:03 +0800338 <a href="tagplugin/if.jsp"><img SRC="images/execute.gif" HSPACE=4 BORDER=0
Hongqing Liufd5ee812014-05-10 16:32:51 +0800339align=TOP></a>
340 <a href="tagplugin/if.jsp">Execute</a>
341 </td>
342 <td WIDTH="30%">
343 <a href="tagplugin/if.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 hei
344ght=24 width=24 align=TOP></a>
345 <a href="tagplugin/if.html">Source</a>
346 </td>
347</tr>
348
349<tr VALIGN=TOP>
350 <td>ForEach&nbsp;</td>
351 <td VALIGN=TOP WIDTH="30%">
刘洪青6266f992017-05-15 21:21:03 +0800352 <a href="tagplugin/foreach.jsp"><img SRC="images/execute.gif" HSPACE=4 BORDER=0
Hongqing Liufd5ee812014-05-10 16:32:51 +0800353align=TOP></a>
354 <a href="tagplugin/foreach.jsp">Execute</a>
355 </td>
356 <td WIDTH="30%">
357 <a href="tagplugin/foreach.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 hei
358ght=24 width=24 align=TOP></a>
359 <a href="tagplugin/foreach.html">Source</a>
360 </td>
361</tr>
362
363<tr VALIGN=TOP>
364 <td>Choose&nbsp;</td>
365 <td VALIGN=TOP WIDTH="30%">
366 <a href="tagplugin/choose.jsp"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP></a>
367 <a href="tagplugin/choose.jsp">Execute</a>
368 </td>
369 <td WIDTH="30%">
370 <a href="tagplugin/choose.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a>
371 <a href="tagplugin/choose.html">Source</a>
372 </td>
373</tr>
374
375</table>
376
刘洪青6266f992017-05-15 21:21:03 +0800377<br/>
378<b><u><font size="+1">Other Examples</font></u></b><br>
379<table BORDER=0 CELLSPACING=5 WIDTH="85%" >
380
381<tr VALIGN=TOP>
382 <td>FORM Authentication&nbsp;</td>
383 <td VALIGN=TOP WIDTH="30%">
384 <a href="security/protected/index.jsp"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP> Execute</a>
385 </td>
386 <td WIDTH="30%"></td>
387</tr>
388<tr>
389 <td colspan="3">Example that demonstrates protecting a resource and
390 using Form-Based authentication. To access the page the user must
391 have role of either "tomcat" or "role1". By default no user
392 is configured to have these roles.</td>
393</tr>
394
395</table>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800396</body>
397</html>