View | Details | Raw Unified | Return to bug 55383
Collapse All | Expand All

(-)webapps/examples/index.html (-10 / +10 lines)
Lines 14-30 Link Here
14
  See the License for the specific language governing permissions and
14
  See the License for the specific language governing permissions and
15
  limitations under the License.
15
  limitations under the License.
16
-->
16
-->
17
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
17
<!DOCTYPE HTML><html lang="en"><head>
18
<HTML><HEAD><TITLE>Apache Tomcat Examples</TITLE>
18
<meta charset="UTF-8">
19
<META http-equiv=Content-Type content="text/html">
19
<title>Apache Tomcat Examples</title>
20
</HEAD>
20
</head>
21
<BODY>
21
<body>
22
<P>
22
<p>
23
<H3>Apache Tomcat Examples</H3>
23
<h3>Apache Tomcat Examples</H3>
24
<P></P>
24
<p></p>
25
<ul>
25
<ul>
26
<li><a href="servlets">Servlets examples</a></li>
26
<li><a href="servlets">Servlets examples</a></li>
27
<li><a href="jsp">JSP Examples</a></li>
27
<li><a href="jsp">JSP Examples</a></li>
28
<li><a href="websocket">WebSocket Examples</a></li>
28
<li><a href="websocket/index.xhtml">WebSocket Examples</a></li>
29
</ul>
29
</ul>
30
</BODY></HTML>
30
</body></html>
(-)webapps/examples/jsp/index.html (-191 / +164 lines)
Lines 1-5 Link Here
1
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
2
<html>
3
<!--
1
<!--
4
 Licensed to the Apache Software Foundation (ASF) under one or more
2
 Licensed to the Apache Software Foundation (ASF) under one or more
5
  contributor license agreements.  See the NOTICE file distributed with
3
  contributor license agreements.  See the NOTICE file distributed with
Lines 16-30 Link Here
16
  See the License for the specific language governing permissions and
14
  See the License for the specific language governing permissions and
17
  limitations under the License.
15
  limitations under the License.
18
-->
16
-->
17
<!DOCTYPE html><html lang="en">
19
<head>
18
<head>
20
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
19
   <meta charset="UTF-8"/>
21
   <meta name="GENERATOR" content="Mozilla/4.61 [en] (WinNT; I) [Netscape]">
20
   <meta name="Author" content="Anil K. Vijendran" />
22
   <meta name="Author" content="Anil K. Vijendran">
23
   <title>JSP Examples</title>
21
   <title>JSP Examples</title>
22
   <style type="text/css">
23
   img { border: 0; }
24
   th { text-align: left; }
25
   tr { vertical-align: top; }
26
   </style>
24
</head>
27
</head>
25
<body bgcolor="#FFFFFF">
28
<body>
26
<b><font face="Arial, Helvetica, sans-serif"><font size=+2>JSP
29
<h1>JSP
27
Samples</font></font></b>
30
Samples</h1>
28
<p>This is a collection of samples demonstrating the usage of different
31
<p>This is a collection of samples demonstrating the usage of different
29
parts of the Java Server Pages (JSP) specification.  Both JSP 2.0 and
32
parts of the Java Server Pages (JSP) specification.  Both JSP 2.0 and
30
JSP 1.2 examples are presented below.
33
JSP 1.2 examples are presented below.
Lines 34-373 Link Here
34
They will not work if you are viewing these pages via a
37
They will not work if you are viewing these pages via a
35
"file://..." URL.
38
"file://..." URL.
36
<p>To navigate your way through the examples, the following icons will
39
<p>To navigate your way through the examples, the following icons will
37
help:
40
help:</p>
38
<br>&nbsp;
41
<ul style="list-style-type: none; padding-left: 0;">
39
<table BORDER=0 CELLSPACING=5 WIDTH="85%" >
42
<li><img src="images/execute.gif" alt=""> Execute the example</li>
40
<tr VALIGN=TOP>
43
<li><img src="images/code.gif" alt=""> Look at the source code for the example</li>
41
<td WIDTH="30"><img SRC="images/execute.gif" ></td>
44
<!-- <li><img src="images/read.gif" alt=""> Read more about this feature</li> -->
45
<li><img src="images/return.gif" alt=""> Return to this screen</li>
46
</ul>
42
47
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.
48
<p>Tip: For session scoped beans to work, the cookies must be enabled.
67
This can be done using browser options.
49
This can be done using browser options.</p>
68
<br>&nbsp;
50
<h2>JSP 2.0 Examples</h2>
69
<br>
70
<b><u><font size="+1">JSP 2.0 Examples</font></u></b><br>
71
51
72
<table BORDER=0 CELLSPACING=5 WIDTH="85%" >
52
<table style="width: 85%;">
73
<tr valign=TOP>
53
<tr>
74
<td><b>Expression Language</b></td>
54
<th colspan="3">Expression Language</th>
75
</tr>
55
</tr>
76
56
77
<tr valign=TOP>
57
<tr>
78
<td>Basic Arithmetic</td>
58
<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>
59
<td style="width: 30%;"><a href="jsp2/el/basic-arithmetic.jsp"><img src="images/execute.gif" alt=""></a><a href="jsp2/el/basic-arithmetic.jsp">Execute</a></td>
80
60
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>
61
<td style="width: 30%;"><a href="jsp2/el/basic-arithmetic.html"><img src="images/code.gif" alt=""></a><a href="jsp2/el/basic-arithmetic.html">Source</a></td>
82
</tr>
62
</tr>
83
63
84
<tr valign=TOP>
64
<tr>
85
<td>Basic Comparisons</td>
65
<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>
66
<td style="width: 30%;"><a href="jsp2/el/basic-comparisons.jsp"><img src="images/execute.gif" alt=""></a><a href="jsp2/el/basic-comparisons.jsp">Execute</a></td>
87
67
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>
68
<td style="width: 30%;"><a href="jsp2/el/basic-comparisons.html"><img src="images/code.gif" alt=""></a><a href="jsp2/el/basic-comparisons.html">Source</a></td>
89
</tr>
69
</tr>
90
70
91
<tr valign=TOP>
71
<tr>
92
<td>Implicit Objects</td>
72
<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>
73
<td style="width: 30%;"><a href="jsp2/el/implicit-objects.jsp?foo=bar"><img src="images/execute.gif" alt=""></a><a href="jsp2/el/implicit-objects.jsp?foo=bar">Execute</a></td>
94
74
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>
75
<td style="width: 30%;"><a href="jsp2/el/implicit-objects.html"><img src="images/code.gif" alt=""></a><a href="jsp2/el/implicit-objects.html">Source</a></td>
96
</tr>
76
</tr>
97
<tr valign=TOP>
77
<tr>
98
78
99
<td>Functions</td>
79
<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>
80
<td style="width: 30%;"><a href="jsp2/el/functions.jsp?foo=JSP+2.0"><img src="images/execute.gif" alt=""></a><a href="jsp2/el/functions.jsp?foo=JSP+2.0">Execute</a></td>
101
81
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>
82
<td style="width: 30%;"><a href="jsp2/el/functions.html"><img src="images/code.gif" alt=""></a><a href="jsp2/el/functions.html">Source</a></td>
103
</tr>
83
</tr>
104
84
105
<tr valign=TOP>
85
<tr>
106
<td>Composite Expressions</td>
86
<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>
87
<td style="width: 30%;"><a href="jsp2/el/composite.jsp"><img src="images/execute.gif" alt=""></a><a href="jsp2/el/composite.jsp">Execute</a></td>
108
88
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>
89
<td style="width: 30%;"><a href="jsp2/el/composite.html"><img src="images/code.gif" alt=""></a><a href="jsp2/el/composite.html">Source</a></td>
110
</tr>
90
</tr>
111
91
112
92
113
<tr valign=TOP>
93
<tr>
114
<td><br><b>SimpleTag Handlers and JSP Fragments</b></td>
94
<th colspan="3"><br />SimpleTag Handlers and JSP Fragments</th>
115
</tr>
95
</tr>
116
96
117
<tr valign=TOP>
97
<tr>
118
<td>Hello World Tag</td>
98
<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>
99
<td style="width: 30%;"><a href="jsp2/simpletag/hello.jsp"><img src="images/execute.gif" alt=""></a><a href="jsp2/simpletag/hello.jsp">Execute</a></td>
120
100
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>
101
<td style="width: 30%;"><a href="jsp2/simpletag/hello.html"><img src="images/code.gif" alt=""></a><a href="jsp2/simpletag/hello.html">Source</a></td>
122
</tr>
102
</tr>
123
103
124
<tr valign=TOP>
104
<tr>
125
<td>Repeat Tag</td>
105
<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>
106
<td style="width: 30%;"><a href="jsp2/simpletag/repeat.jsp"><img src="images/execute.gif" alt=""></a><a href="jsp2/simpletag/repeat.jsp">Execute</a></td>
127
107
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>
108
<td style="width: 30%;"><a href="jsp2/simpletag/repeat.html"><img src="images/code.gif" alt=""></a><a href="jsp2/simpletag/repeat.html">Source</a></td>
129
</tr>
109
</tr>
130
110
131
<tr valign=TOP>
111
<tr>
132
<td>Book Example</td>
112
<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>
113
<td style="width: 30%;"><a href="jsp2/simpletag/book.jsp"><img src="images/execute.gif" alt=""></a><a href="jsp2/simpletag/book.jsp">Execute</a></td>
134
114
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>
115
<td style="width: 30%;"><a href="jsp2/simpletag/book.html"><img src="images/code.gif" alt=""></a><a href="jsp2/simpletag/book.html">Source</a></td>
136
</tr>
116
</tr>
137
117
138
<tr valign=TOP>
118
<tr>
139
<td><br><b>Tag Files</b></td>
119
<th colspan="3"><br />Tag Files</th>
140
</tr>
120
</tr>
141
121
142
<tr valign=TOP>
122
<tr>
143
<td>Hello World Tag File</td>
123
<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>
124
<td style="width: 30%;"><a href="jsp2/tagfiles/hello.jsp"><img src="images/execute.gif" alt=""></a><a href="jsp2/tagfiles/hello.jsp">Execute</a></td>
145
125
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>
126
<td style="width: 30%;"><a href="jsp2/tagfiles/hello.html"><img src="images/code.gif" alt=""></a><a href="jsp2/tagfiles/hello.html">Source</a></td>
147
</tr>
127
</tr>
148
128
149
<tr valign=TOP>
129
<tr>
150
<td>Panel Tag File</td>
130
<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>
131
<td style="width: 30%;"><a href="jsp2/tagfiles/panel.jsp"><img src="images/execute.gif" alt=""></a><a href="jsp2/tagfiles/panel.jsp">Execute</a></td>
152
132
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>
133
<td style="width: 30%;"><a href="jsp2/tagfiles/panel.html"><img src="images/code.gif" alt=""></a><a href="jsp2/tagfiles/panel.html">Source</a></td>
154
</tr>
134
</tr>
155
135
156
<tr valign=TOP>
136
<tr>
157
<td>Display Products Example</td>
137
<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>
138
<td style="width: 30%;"><a href="jsp2/tagfiles/products.jsp"><img src="images/execute.gif" alt=""></a><a href="jsp2/tagfiles/products.jsp">Execute</a></td>
159
139
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>
140
<td style="width: 30%;"><a href="jsp2/tagfiles/products.html"><img src="images/code.gif" alt=""></a><a href="jsp2/tagfiles/products.html">Source</a></td>
161
</tr>
141
</tr>
162
142
163
<tr valign=TOP>
143
<tr>
164
<td><br><b>New JSP XML Syntax (.jspx)</b></td>
144
<th colspan="3"><br />New JSP XML Syntax (.jspx)</th>
165
</tr>
145
</tr>
166
146
167
<tr valign=TOP>
147
<tr>
168
<td>XHTML Basic Example</td>
148
<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>
149
<td style="width: 30%;"><a href="jsp2/jspx/basic.jspx"><img src="images/execute.gif" alt=""></a><a href="jsp2/jspx/basic.jspx">Execute</a></td>
170
150
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>
151
<td style="width: 30%;"><a href="jsp2/jspx/basic.html"><img src="images/code.gif" alt=""></a><a href="jsp2/jspx/basic.html">Source</a></td>
172
</tr>
152
</tr>
173
153
174
<tr valign=TOP>
154
<tr>
175
<td>SVG (Scalable Vector Graphics)</td>
155
<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>
156
<td style="width: 30%;"><a href="jsp2/jspx/svgexample.html"><img src="images/execute.gif" alt=""></a><a href="jsp2/jspx/svgexample.html">Execute</a></td>
177
157
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>
158
<td style="width: 30%;"><a href="jsp2/jspx/textRotate.html"><img src="images/code.gif" alt=""></a><a href="jsp2/jspx/textRotate.html">Source</a></td>
179
</tr>
159
</tr>
180
160
181
<tr valign=TOP>
161
<tr>
182
<td><br><b>Other JSP 2.0 Features</b></td>
162
<th colspan="3"><br />Other JSP 2.0 Features</th>
183
</tr>
163
</tr>
184
164
185
<tr valign=TOP>
165
<tr>
186
<td>&lt;jsp:attribute&gt; and &lt;jsp:body&gt;</td>
166
<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>
167
<td style="width: 30%;"><a href="jsp2/jspattribute/jspattribute.jsp"><img src="images/execute.gif" alt=""></a><a href="jsp2/jspattribute/jspattribute.jsp">Execute</a></td>
188
168
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>
169
<td style="width: 30%;"><a href="jsp2/jspattribute/jspattribute.html"><img src="images/code.gif" alt=""></a><a href="jsp2/jspattribute/jspattribute.html">Source</a></td>
190
</tr>
170
</tr>
191
171
192
<tr valign=TOP>
172
<tr>
193
<td>Shuffle Example</td>
173
<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>
174
<td style="width: 30%;"><a href="jsp2/jspattribute/shuffle.jsp"><img src="images/execute.gif" alt=""></a><a href="jsp2/jspattribute/shuffle.jsp">Execute</a></td>
195
175
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>
176
<td style="width: 30%;"><a href="jsp2/jspattribute/shuffle.html"><img src="images/code.gif" alt=""></a><a href="jsp2/jspattribute/shuffle.html">Source</a></td>
197
</tr>
177
</tr>
198
178
199
<tr valign=TOP>
179
<tr>
200
<td>Attributes With Dynamic Names</td>
180
<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>
181
<td style="width: 30%;"><a href="jsp2/misc/dynamicattrs.jsp"><img src="images/execute.gif" alt=""></a><a href="jsp2/misc/dynamicattrs.jsp">Execute</a></td>
202
182
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>
183
<td style="width: 30%;"><a href="jsp2/misc/dynamicattrs.html"><img src="images/code.gif" alt=""></a><a href="jsp2/misc/dynamicattrs.html">Source</a></td>
204
</tr>
184
</tr>
205
185
206
<tr valign=TOP>
186
<tr>
207
<td>JSP Configuration</td>
187
<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>
188
<td style="width: 30%;"><a href="jsp2/misc/config.jsp"><img src="images/execute.gif" alt=""></a><a href="jsp2/misc/config.jsp">Execute</a></td>
209
189
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>
190
<td style="width: 30%;"><a href="jsp2/misc/config.html"><img src="images/code.gif" alt=""></a><a href="jsp2/misc/config.html">Source</a></td>
211
</tr>
191
</tr>
212
192
213
</table>
193
</table>
214
194
215
<br>
195
<h2>JSP 1.2 Examples</h2>
216
<b><u><font size="+1">JSP 1.2 Examples</font></u></b><br>
196
<table style="width: 85%;">
217
<table BORDER=0 CELLSPACING=5 WIDTH="85%" >
197
<tr>
218
<tr VALIGN=TOP>
198
<td>Numberguess</td>
219
<td>Numberguess&nbsp;</td>
220
199
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>
200
<td style="width: 30%;"><a href="num/numguess.jsp"><img src="images/execute.gif" alt=""></a><a href="num/numguess.jsp">Execute</a></td>
222
201
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>
202
<td style="width: 30%;"><a href="num/numguess.html"><img src="images/code.gif" alt=""></a><a href="num/numguess.html">Source</a></td>
224
</tr>
203
</tr>
225
204
226
<tr VALIGN=TOP>
205
<tr>
227
<td>Date&nbsp;</td>
206
<td>Date</td>
228
207
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>
208
<td style="width: 30%;"><a href="dates/date.jsp"><img src="images/execute.gif" alt=""></a><a href="dates/date.jsp">Execute</a></td>
230
209
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>
210
<td style="width: 30%;"><a href="dates/date.html"><img src="images/code.gif" alt=""></a><a href="dates/date.html">Source</a></td>
232
</tr>
211
</tr>
233
212
234
<tr VALIGN=TOP>
213
<tr>
235
<td>Snoop</td>
214
<td>Snoop</td>
236
215
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>
216
<td style="width: 30%;"><a href="snp/snoop.jsp"><img src="images/execute.gif" alt=""></a><a href="snp/snoop.jsp">Execute</a></td>
238
217
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>
218
<td style="width: 30%;"><a href="snp/snoop.html"><img src="images/code.gif" alt=""></a><a href="snp/snoop.html">Source</a></td>
240
</tr>
219
</tr>
241
220
242
<tr VALIGN=TOP>
221
<tr>
243
<td>ErrorPage&nbsp;</td>
222
<td>ErrorPage</td>
244
223
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>
224
<td style="width: 30%;"><a href="error/error.html"><img src="images/execute.gif" alt=""></a><a href="error/error.html">Execute</a></td>
246
225
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>
226
<td style="width: 30%;"><a href="error/er.html"><img src="images/code.gif" alt=""></a><a href="error/er.html">Source</a></td>
248
</tr>
227
</tr>
249
228
250
<tr VALIGN=TOP>
229
<tr>
251
<td>Carts&nbsp;</td>
230
<td>Carts</td>
252
231
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>
232
<td style="width: 30%;"><a href="sessions/carts.html"><img src="images/execute.gif" alt=""></a><a href="sessions/carts.html">Execute</a></td>
254
233
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>
234
<td style="width: 30%;"><a href="sessions/crt.html"><img src="images/code.gif" alt=""></a><a href="sessions/crt.html">Source</a></td>
256
</tr>
235
</tr>
257
236
258
<tr VALIGN=TOP>
237
<tr>
259
<td>Checkbox&nbsp;</td>
238
<td>Checkbox</td>
260
239
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>
240
<td style="width: 30%;"><a href="checkbox/check.html"><img src="images/execute.gif" alt=""></a><a href="checkbox/check.html">Execute</a></td>
262
241
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>
242
<td style="width: 30%;"><a href="checkbox/cresult.html"><img src="images/code.gif" alt=""></a><a href="checkbox/cresult.html">Source</a></td>
264
</tr>
243
</tr>
265
244
266
<tr VALIGN=TOP>
245
<tr>
267
<td>Color&nbsp;</td>
246
<td>Color</td>
268
247
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>
248
<td style="width: 30%;"><a href="colors/colors.html"><img src="images/execute.gif" alt=""></a><a href="colors/colors.html">Execute</a></td>
270
249
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>
250
<td style="width: 30%;"><a href="colors/clr.html"><img src="images/code.gif" alt=""></a><a href="colors/clr.html">Source</a></td>
272
</tr>
251
</tr>
273
252
274
<tr VALIGN=TOP>
253
<tr>
275
<td>Calendar&nbsp;</td>
254
<td>Calendar</td>
276
255
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>
256
<td style="width: 30%;"><a href="cal/login.html"><img src="images/execute.gif" alt=""></a><a href="cal/login.html">Execute</a></td>
278
257
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>
258
<td style="width: 30%;"><a href="cal/calendar.html"><img src="images/code.gif" alt=""></a><a href="cal/calendar.html">Source</a></td>
280
</tr>
259
</tr>
281
260
282
<tr VALIGN=TOP>
261
<tr>
283
<td>Include&nbsp;</td>
262
<td>Include</td>
284
263
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>
264
<td style="width: 30%;"><a href="include/include.jsp"><img src="images/execute.gif" alt=""></a><a href="include/include.jsp">Execute</a></td>
286
265
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>
266
<td style="width: 30%;"><a href="include/inc.html"><img src="images/code.gif" alt=""></a><a href="include/inc.html">Source</a></td>
288
</tr>
267
</tr>
289
268
290
<tr VALIGN=TOP>
269
<tr>
291
<td>Forward&nbsp;</td>
270
<td>Forward</td>
292
271
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>
272
<td style="width: 30%;"><a href="forward/forward.jsp"><img src="images/execute.gif" alt=""></a><a href="forward/forward.jsp">Execute</a></td>
294
273
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>
274
<td style="width: 30%;"><a href="forward/fwd.html"><img src="images/code.gif" alt=""></a><a href="forward/fwd.html">Source</a></td>
296
</tr>
275
</tr>
297
276
298
<tr VALIGN=TOP>
277
<tr>
299
<td>Plugin&nbsp;</td>
278
<td>Plugin</td>
300
279
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>
280
<td style="width: 30%;"><a href="plugin/plugin.jsp"><img src="images/execute.gif" alt=""></a><a href="plugin/plugin.jsp">Execute</a></td>
302
281
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>
282
<td style="width: 30%;"><a href="plugin/plugin.html"><img src="images/code.gif" alt=""></a><a href="plugin/plugin.html">Source</a></td>
304
</tr>
283
</tr>
305
284
306
<tr VALIGN=TOP>
285
<tr>
307
<td>JSP-Servlet-JSP&nbsp;</td>
286
<td>JSP-Servlet-JSP</td>
308
287
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>
288
<td style="width: 30%;"><a href="jsptoserv/jsptoservlet.jsp"><img src="images/execute.gif" alt=""></a><a href="jsptoserv/jsptoservlet.jsp">Execute</a></td>
310
289
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>
290
<td style="width: 30%;"><a href="jsptoserv/jts.html"><img src="images/code.gif" alt=""></a><a href="jsptoserv/jts.html">Source</a></td>
312
</tr>
291
</tr>
313
292
314
<tr VALIGN=TOP>
293
<tr>
315
<td>Custom tag example</td>
294
<td>Custom tag example</td>
316
295
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>
296
<td style="width: 30%;"><a href="simpletag/foo.jsp"><img src="images/execute.gif" alt=""></a><a href="simpletag/foo.jsp">Execute</a></td>
318
297
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>
298
<td style="width: 30%;"><a href="simpletag/foo.html"><img src="images/code.gif" alt=""></a><a href="simpletag/foo.html">Source</a></td>
320
</tr>
299
</tr>
321
300
322
<tr valign=TOP>
301
<tr>
323
<td>XML syntax example</td>
302
<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>
303
<td style="width: 30%;"><a href="xml/xml.jsp"><img src="images/execute.gif" alt=""></a><a href="xml/xml.jsp">Execute</a></td>
325
304
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>
305
<td style="width: 30%;"><a href="xml/xml.html"><img src="images/code.gif" alt=""></a><a href="xml/xml.html">Source</a></td>
327
</tr>
306
</tr>
328
307
329
</table>
308
</table>
330
309
331
<br/>
310
<h2>Tag Plugins</h2>
332
<b><u><font size="+1">Tag Plugins</font></u></b><br>
311
<table style="width: 85%;">
333
<table BORDER=0 CELLSPACING=5 WIDTH="85%" >
334
312
335
<tr VALIGN=TOP>
313
<tr>
336
  <td>If&nbsp;</td>
314
  <td>If</td>
337
  <td VALIGN=TOP WIDTH="30%">
315
  <td style="width: 30%;">
338
    <a href="tagplugin/if.jsp"><img SRC="images/execute.gif" HSPACE=4 BORDER=0
316
    <a href="tagplugin/if.jsp"><img src="images/execute.gif" alt=""></a>
339
align=TOP></a>
340
    <a href="tagplugin/if.jsp">Execute</a>
317
    <a href="tagplugin/if.jsp">Execute</a>
341
  </td>
318
  </td>
342
  <td WIDTH="30%">
319
  <td style="width: 30%;">
343
    <a href="tagplugin/if.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 hei
320
    <a href="tagplugin/if.html"><img src="images/code.gif" alt=""></a>
344
ght=24 width=24 align=TOP></a>
345
    <a href="tagplugin/if.html">Source</a>
321
    <a href="tagplugin/if.html">Source</a>
346
  </td>
322
  </td>
347
</tr>
323
</tr>
348
324
349
<tr VALIGN=TOP>
325
<tr>
350
  <td>ForEach&nbsp;</td>
326
  <td>ForEach</td>
351
  <td VALIGN=TOP WIDTH="30%">
327
  <td style="width: 30%;">
352
    <a href="tagplugin/foreach.jsp"><img SRC="images/execute.gif" HSPACE=4 BORDER=0
328
    <a href="tagplugin/foreach.jsp"><img src="images/execute.gif" alt=""></a>
353
align=TOP></a>
354
    <a href="tagplugin/foreach.jsp">Execute</a>
329
    <a href="tagplugin/foreach.jsp">Execute</a>
355
  </td>
330
  </td>
356
  <td WIDTH="30%">
331
  <td style="width: 30%;">
357
    <a href="tagplugin/foreach.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 hei
332
    <a href="tagplugin/foreach.html"><img src="images/code.gif" alt=""></a>
358
ght=24 width=24 align=TOP></a>
359
    <a href="tagplugin/foreach.html">Source</a>
333
    <a href="tagplugin/foreach.html">Source</a>
360
  </td>
334
  </td>
361
</tr>
335
</tr>
362
336
363
<tr VALIGN=TOP>
337
<tr>
364
  <td>Choose&nbsp;</td>
338
  <td>Choose</td>
365
  <td VALIGN=TOP WIDTH="30%">
339
  <td style="width: 30%;">
366
    <a href="tagplugin/choose.jsp"><img SRC="images/execute.gif" HSPACE=4 BORDER=0  align=TOP></a>
340
    <a href="tagplugin/choose.jsp"><img src="images/execute.gif" alt=""></a>
367
    <a href="tagplugin/choose.jsp">Execute</a>
341
    <a href="tagplugin/choose.jsp">Execute</a>
368
  </td>
342
  </td>
369
  <td WIDTH="30%">
343
  <td style="width: 30%;">
370
    <a href="tagplugin/choose.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a>
344
    <a href="tagplugin/choose.html"><img src="images/code.gif" alt=""></a>
371
    <a href="tagplugin/choose.html">Source</a>
345
    <a href="tagplugin/choose.html">Source</a>
372
  </td>
346
  </td>
373
</tr>
347
</tr>
Lines 374-389 Link Here
374
348
375
</table>
349
</table>
376
350
377
<br/>
351
<h2>Other Examples</h2>
378
<b><u><font size="+1">Other Examples</font></u></b><br>
352
<table style="width: 85%;">
379
<table BORDER=0 CELLSPACING=5 WIDTH="85%" >
380
353
381
<tr VALIGN=TOP>
354
<tr>
382
  <td>FORM Authentication&nbsp;</td>
355
  <td>FORM Authentication</td>
383
  <td VALIGN=TOP WIDTH="30%">
356
  <td style="width: 30%;">
384
    <a href="security/protected/index.jsp"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP> Execute</a>
357
    <a href="security/protected/index.jsp"><img src="images/execute.gif" alt=""> Execute</a>
385
  </td>
358
  </td>
386
  <td WIDTH="30%"></td>
359
  <td style="width: 30%;"></td>
387
</tr>
360
</tr>
388
<tr>
361
<tr>
389
  <td colspan="3">Example that demonstrates protecting a resource and
362
  <td colspan="3">Example that demonstrates protecting a resource and
(-)webapps/examples/servlets/index.html (-97 / +85 lines)
Lines 14-30 Link Here
14
  See the License for the specific language governing permissions and
14
  See the License for the specific language governing permissions and
15
  limitations under the License.
15
  limitations under the License.
16
-->
16
-->
17
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
17
<!DOCTYPE html><html lang="en">
18
<html>
19
<head>
18
<head>
20
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
19
   <meta charset="UTF-8" />
21
   <meta name="GENERATOR" content="Mozilla/4.61 [en] (WinNT; I) [Netscape]">
20
   <meta name="Author" content="Anil K. Vijendran" />
22
   <meta name="Author" content="Anil K. Vijendran">
23
   <title>Servlet Examples</title>
21
   <title>Servlet Examples</title>
22
   <style type="text/css">
23
   img { border: 0; }
24
   th { text-align: left; }
25
   tr { vertical-align: top; }
26
   </style>
24
</head>
27
</head>
25
<body bgcolor="#FFFFFF">
28
<body>
26
<b><font face="Arial, Helvetica, sans-serif"><font size=+2>Servlet
29
<h1>Servlet
27
Examples with Code</font></font></b>
30
Examples with Code</h1>
28
<p>This is a collection of examples which demonstrate some of the more
31
<p>This is a collection of examples which demonstrate some of the more
29
frequently used parts of the Servlet API. Familiarity with the Java(tm)
32
frequently used parts of the Servlet API. Familiarity with the Java(tm)
30
Programming Language is assumed.
33
Programming Language is assumed.
Lines 36-115 Link Here
36
When playing with the Cookie and Session Examples, jump back to the Headers
39
When playing with the Cookie and Session Examples, jump back to the Headers
37
Example to see exactly what your browser is sending the server.
40
Example to see exactly what your browser is sending the server.
38
<p>To navigate your way through the examples, the following icons will
41
<p>To navigate your way through the examples, the following icons will
39
help:
42
help:</p>
40
<br>&nbsp;
43
<ul style="list-style-type: none; padding-left: 0;">
41
<table BORDER=0 CELLSPACING=5 WIDTH="85%" >
44
<li><img src="images/execute.gif" alt=""> Execute the example</li>
42
<tr VALIGN=TOP>
45
<li><img src="images/code.gif" alt=""> Look at the source code for the example</li>
43
<td WIDTH="30"><img SRC="images/execute.gif" ></td>
46
<!-- <li><img src="images/read.gif" alt=""> Read more about this feature</li> -->
47
<li><img src="images/return.gif" alt=""> Return to this screen</li>
48
</ul>
44
49
45
<td>Execute the example</td>
46
</tr>
47
48
<tr VALIGN=TOP>
49
<td WIDTH="30"><img SRC="images/code.gif" height=24 width=24></td>
50
51
<td>Look at the source code for the example</td>
52
</tr>
53
54
<tr VALIGN=TOP>
55
<td WIDTH="30"><img SRC="images/return.gif" height=24 width=24></td>
56
57
<td>Return to this screen</td>
58
</tr>
59
</table>
60
61
<p>Tip: To see the cookie interactions with your browser, try turning on
50
<p>Tip: To see the cookie interactions with your browser, try turning on
62
the "notify when setting a cookie" option in your browser preferences.
51
the "notify when setting a cookie" option in your browser preferences.
63
This will let you see when a session is created and give some feedback
52
This will let you see when a session is created and give some feedback
64
when looking at the cookie demo.
53
when looking at the cookie demo.</p>
65
<br>&nbsp;
54
<table style="width: 85%;" >
66
<table BORDER=0 CELLSPACING=5 WIDTH="85%" >
55
<tr>
67
<tr VALIGN=TOP>
68
<td>Hello World</td>
56
<td>Hello World</td>
69
57
70
<td VALIGN=TOP WIDTH="30%"><a href="servlet/HelloWorldExample"><img SRC="images/execute.gif" HSPACE=4 BORDER=0  align=TOP></a><a href="servlet/HelloWorldExample">Execute</a></td>
58
<td style="width: 30%;"><a href="servlet/HelloWorldExample"><img SRC="images/execute.gif" alt=""></a><a href="servlet/HelloWorldExample">Execute</a></td>
71
59
72
<td WIDTH="30%"><a href="helloworld.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="helloworld.html">Source</a></td>
60
<td style="width: 30%;"><a href="helloworld.html"><img SRC="images/code.gif" alt=""></a><a href="helloworld.html">Source</a></td>
73
</tr>
61
</tr>
74
62
75
<tr VALIGN=TOP>
63
<tr>
76
<td>Request Info</td>
64
<td>Request Info</td>
77
65
78
<td WIDTH="30%"><a href="servlet/RequestInfoExample"><img SRC="images/execute.gif" HSPACE=4 BORDER=0  align=TOP></a><a href="servlet/RequestInfoExample">Execute</a></td>
66
<td style="width: 30%;"><a href="servlet/RequestInfoExample"><img SRC="images/execute.gif" alt=""></a><a href="servlet/RequestInfoExample">Execute</a></td>
79
67
80
<td WIDTH="30%"><a href="reqinfo.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="reqinfo.html">Source</a></td>
68
<td style="width: 30%;"><a href="reqinfo.html"><img SRC="images/code.gif" alt=""></a><a href="reqinfo.html">Source</a></td>
81
</tr>
69
</tr>
82
70
83
<tr VALIGN=TOP>
71
<tr>
84
<td>Request Headers</td>
72
<td>Request Headers</td>
85
73
86
<td WIDTH="30%"><a href="servlet/RequestHeaderExample"><img SRC="images/execute.gif" HSPACE=4 BORDER=0  align=TOP></a><a href="servlet/RequestHeaderExample">Execute</a></td>
74
<td style="width: 30%;"><a href="servlet/RequestHeaderExample"><img SRC="images/execute.gif" alt=""></a><a href="servlet/RequestHeaderExample">Execute</a></td>
87
75
88
<td WIDTH="30%"><a href="reqheaders.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="reqheaders.html">Source</a></td>
76
<td style="width: 30%;"><a href="reqheaders.html"><img SRC="images/code.gif" alt=""></a><a href="reqheaders.html">Source</a></td>
89
</tr>
77
</tr>
90
78
91
<tr VALIGN=TOP>
79
<tr>
92
<td>Request Parameters</td>
80
<td>Request Parameters</td>
93
81
94
<td WIDTH="30%"><a href="servlet/RequestParamExample"><img SRC="images/execute.gif" HSPACE=4 BORDER=0  align=TOP></a><a href="servlet/RequestParamExample">Execute</a></td>
82
<td style="width: 30%;"><a href="servlet/RequestParamExample"><img SRC="images/execute.gif" alt=""></a><a href="servlet/RequestParamExample">Execute</a></td>
95
83
96
<td WIDTH="30%"><a href="reqparams.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="reqparams.html">Source</a></td>
84
<td style="width: 30%;"><a href="reqparams.html"><img SRC="images/code.gif" alt=""></a><a href="reqparams.html">Source</a></td>
97
</tr>
85
</tr>
98
86
99
<tr VALIGN=TOP>
87
<tr>
100
<td>Cookies</td>
88
<td>Cookies</td>
101
89
102
<td WIDTH="30%"><a href="servlet/CookieExample"><img SRC="images/execute.gif" HSPACE=4 BORDER=0  align=TOP></a><a href="servlet/CookieExample">Execute</a></td>
90
<td style="width: 30%;"><a href="servlet/CookieExample"><img SRC="images/execute.gif" alt=""></a><a href="servlet/CookieExample">Execute</a></td>
103
91
104
<td WIDTH="30%"><a href="cookies.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="cookies.html">Source</a></td>
92
<td style="width: 30%;"><a href="cookies.html"><img SRC="images/code.gif" alt=""></a><a href="cookies.html">Source</a></td>
105
</tr>
93
</tr>
106
94
107
<tr VALIGN=TOP>
95
<tr>
108
<td>Sessions</td>
96
<td>Sessions</td>
109
97
110
<td WIDTH="30%"><a href="servlet/SessionExample"><img SRC="images/execute.gif" HSPACE=4 BORDER=0  align=TOP></a><a href="servlet/SessionExample">Execute</a></td>
98
<td style="width: 30%;"><a href="servlet/SessionExample"><img SRC="images/execute.gif" alt=""></a><a href="servlet/SessionExample">Execute</a></td>
111
99
112
<td WIDTH="30%"><a href="sessions.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="sessions.html">Source</a></td>
100
<td style="width: 30%;"><a href="sessions.html"><img SRC="images/code.gif" alt=""></a><a href="sessions.html">Source</a></td>
113
</tr>
101
</tr>
114
</table>
102
</table>
115
103
Lines 118-195 Link Here
118
of code. Code not important to understand the example has been removed
106
of code. Code not important to understand the example has been removed
119
for clarity.</p>
107
for clarity.</p>
120
108
121
<b><u><font size="+1">Other Examples</font></u></b><br>
109
<h2>Other Examples</h2>
122
<table BORDER=0 CELLSPACING=5 WIDTH="85%" >
110
<table style="width: 85%;" >
123
111
124
<tr>
112
<tr>
125
  <td colspan="3">Servlet 3.0 Asynchronous processing examples:</td>
113
  <th colspan="3">Servlet 3.0 Asynchronous processing examples:</th>
126
</tr>
114
</tr>
127
<tr VALIGN=TOP>
115
<tr>
128
  <td>async0&nbsp;</td>
116
  <td>async0</td>
129
  <td VALIGN=TOP WIDTH="30%">
117
  <td style="width: 30%;">
130
    <a href="../async/async0"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP> Execute</a>
118
    <a href="../async/async0"><img SRC="images/execute.gif" alt=""> Execute</a>
131
  </td>
119
  </td>
132
  <td WIDTH="30%"></td>
120
  <td style="width: 30%;"></td>
133
</tr>
121
</tr>
134
<tr VALIGN=TOP>
122
<tr>
135
  <td>async1&nbsp;</td>
123
  <td>async1</td>
136
  <td VALIGN=TOP WIDTH="30%">
124
  <td style="width: 30%;">
137
    <a href="../async/async1"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP> Execute</a>
125
    <a href="../async/async1"><img SRC="images/execute.gif" alt=""> Execute</a>
138
  </td>
126
  </td>
139
  <td WIDTH="30%"></td>
127
  <td style="width: 30%;"></td>
140
</tr>
128
</tr>
141
<tr VALIGN=TOP>
129
<tr>
142
  <td>async2&nbsp;</td>
130
  <td>async2</td>
143
  <td VALIGN=TOP WIDTH="30%">
131
  <td style="width: 30%;">
144
    <a href="../async/async2"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP> Execute</a>
132
    <a href="../async/async2"><img SRC="images/execute.gif" alt=""> Execute</a>
145
  </td>
133
  </td>
146
  <td WIDTH="30%"></td>
134
  <td style="width: 30%;"></td>
147
</tr>
135
</tr>
148
<tr VALIGN=TOP>
136
<tr>
149
  <td>async3&nbsp;</td>
137
  <td>async3</td>
150
  <td VALIGN=TOP WIDTH="30%">
138
  <td style="width: 30%;">
151
    <a href="../async/async3"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP> Execute</a>
139
    <a href="../async/async3"><img SRC="images/execute.gif" alt=""> Execute</a>
152
  </td>
140
  </td>
153
  <td WIDTH="30%"></td>
141
  <td style="width: 30%;"></td>
154
</tr>
142
</tr>
155
<tr VALIGN=TOP>
143
<tr>
156
  <td>stockticker&nbsp;</td>
144
  <td>stockticker</td>
157
  <td VALIGN=TOP WIDTH="30%">
145
  <td style="width: 30%;">
158
    <a href="../async/stockticker"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP> Execute</a>
146
    <a href="../async/stockticker"><img SRC="images/execute.gif" alt=""> Execute</a>
159
  </td>
147
  </td>
160
  <td WIDTH="30%"></td>
148
  <td style="width: 30%;"></td>
161
</tr>
149
</tr>
162
150
163
<tr>
151
<tr>
164
  <td colspan="3">Comet processing example:<br />
152
  <th colspan="3">Comet processing example:<br />
165
    See the <strong>"Advanced IO"</strong> chapter in the User Guide for
153
    <span style="font-weight: normal;">See the <strong>"Advanced IO"</strong> chapter in the User Guide for
166
    details. This example only works with the HTTP NIO or HTTP APR/native
154
    details. This example only works with the HTTP NIO or HTTP APR/native
167
    connectors as these are the only connectors that support Comet.</td>
155
    connectors as these are the only connectors that support Comet.</span></th>
168
</tr>
156
</tr>
169
<tr VALIGN=TOP>
157
<tr>
170
  <td>Comet Chat&nbsp;</td>
158
  <td>Comet Chat</td>
171
  <td VALIGN=TOP WIDTH="30%">
159
  <td style="width: 30%;">
172
    <a href="chat/"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP> Execute</a>
160
    <a href="chat/"><img SRC="images/execute.gif" alt=""> Execute</a>
173
  </td>
161
  </td>
174
  <td WIDTH="30%"></td>
162
  <td style="width: 30%;"></td>
175
</tr>
163
</tr>
176
164
177
<tr>
165
<tr>
178
  <td colspan="3">Servlet 3.1 Non-blocking IO examples</td>
166
  <th colspan="3">Servlet 3.1 Non-blocking IO examples</th>
179
</tr>
167
</tr>
180
<tr VALIGN=TOP>
168
<tr>
181
  <td>Byte counter&nbsp;</td>
169
  <td>Byte counter</td>
182
  <td VALIGN=TOP WIDTH="30%">
170
  <td style="width: 30%;">
183
    <a href="nonblocking/bytecounter.html"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP> Execute</a>
171
    <a href="nonblocking/bytecounter.html"><img src="images/execute.gif" alt=""> Execute</a>
184
  </td>
172
  </td>
185
  <td WIDTH="30%"></td>
173
  <td style="width: 30%;"></td>
186
</tr>
174
</tr>
187
<tr VALIGN=TOP>
175
<tr>
188
  <td>Number Writer&nbsp;</td>
176
  <td>Number Writer</td>
189
  <td VALIGN=TOP WIDTH="30%">
177
  <td style="width: 30%;">
190
    <a href="nonblocking/numberwriter"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP> Execute</a>
178
    <a href="nonblocking/numberwriter"><img src="images/execute.gif" alt=""> Execute</a>
191
  </td>
179
  </td>
192
  <td WIDTH="30%"></td>
180
  <td style="width: 30%;"></td>
193
</tr>
181
</tr>
194
182
195
</table>
183
</table>
(-)webapps/examples/websocket/chat.html (-125 lines)
Lines 1-125 Link Here
1
<!--
2
  Licensed to the Apache Software Foundation (ASF) under one or more
3
  contributor license agreements.  See the NOTICE file distributed with
4
  this work for additional information regarding copyright ownership.
5
  The ASF licenses this file to You under the Apache License, Version 2.0
6
  (the "License"); you may not use this file except in compliance with
7
  the License.  You may obtain a copy of the License at
8
9
      http://www.apache.org/licenses/LICENSE-2.0
10
11
  Unless required by applicable law or agreed to in writing, software
12
  distributed under the License is distributed on an "AS IS" BASIS,
13
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
  See the License for the specific language governing permissions and
15
  limitations under the License.
16
-->
17
<!DOCTYPE html>
18
<html>
19
<head>
20
    <title>Apache Tomcat WebSocket Examples: Chat</title>
21
    <style type="text/css">
22
        input#chat {
23
            width: 410px
24
        }
25
26
        #console-container {
27
            width: 400px;
28
        }
29
30
        #console {
31
            border: 1px solid #CCCCCC;
32
            border-right-color: #999999;
33
            border-bottom-color: #999999;
34
            height: 170px;
35
            overflow-y: scroll;
36
            padding: 5px;
37
            width: 100%;
38
        }
39
40
        #console p {
41
            padding: 0;
42
            margin: 0;
43
        }
44
    </style>
45
    <script type="text/javascript">
46
        var Chat = {};
47
48
        Chat.socket = null;
49
50
        Chat.connect = (function(host) {
51
            if ('WebSocket' in window) {
52
                Chat.socket = new WebSocket(host);
53
            } else if ('MozWebSocket' in window) {
54
                Chat.socket = new MozWebSocket(host);
55
            } else {
56
                Console.log('Error: WebSocket is not supported by this browser.');
57
                return;
58
            }
59
60
            Chat.socket.onopen = function () {
61
                Console.log('Info: WebSocket connection opened.');
62
                document.getElementById('chat').onkeydown = function(event) {
63
                    if (event.keyCode == 13) {
64
                        Chat.sendMessage();
65
                    }
66
                };
67
            };
68
69
            Chat.socket.onclose = function () {
70
                document.getElementById('chat').onkeydown = null;
71
                Console.log('Info: WebSocket closed.');
72
            };
73
74
            Chat.socket.onmessage = function (message) {
75
                Console.log(message.data);
76
            };
77
        });
78
79
        Chat.initialize = function() {
80
            if (window.location.protocol == 'http:') {
81
                Chat.connect('ws://' + window.location.host + '/examples/websocket/chat');
82
            } else {
83
                Chat.connect('wss://' + window.location.host + '/examples/websocket/chat');
84
            }
85
        };
86
87
        Chat.sendMessage = (function() {
88
            var message = document.getElementById('chat').value;
89
            if (message != '') {
90
                Chat.socket.send(message);
91
                document.getElementById('chat').value = '';
92
            }
93
        });
94
95
        var Console = {};
96
97
        Console.log = (function(message) {
98
            var console = document.getElementById('console');
99
            var p = document.createElement('p');
100
            p.style.wordWrap = 'break-word';
101
            p.innerHTML = message;
102
            console.appendChild(p);
103
            while (console.childNodes.length > 25) {
104
                console.removeChild(console.firstChild);
105
            }
106
            console.scrollTop = console.scrollHeight;
107
        });
108
109
        Chat.initialize();
110
111
    </script>
112
</head>
113
<body>
114
<noscript><h2 style="color: #ff0000">Seems your browser doesn't support Javascript! Websockets rely on Javascript being enabled. Please enable
115
    Javascript and reload this page!</h2></noscript>
116
<div>
117
    <p>
118
        <input type="text" placeholder="type and press enter to chat" id="chat">
119
    </p>
120
    <div id="console-container">
121
        <div id="console"></div>
122
    </div>
123
</div>
124
</body>
125
</html>
(-)webapps/examples/websocket/chat.xhtml (+135 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!--
3
  Licensed to the Apache Software Foundation (ASF) under one or more
4
  contributor license agreements.  See the NOTICE file distributed with
5
  this work for additional information regarding copyright ownership.
6
  The ASF licenses this file to You under the Apache License, Version 2.0
7
  (the "License"); you may not use this file except in compliance with
8
  the License.  You may obtain a copy of the License at
9
10
      http://www.apache.org/licenses/LICENSE-2.0
11
12
  Unless required by applicable law or agreed to in writing, software
13
  distributed under the License is distributed on an "AS IS" BASIS,
14
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
  See the License for the specific language governing permissions and
16
  limitations under the License.
17
-->
18
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
19
<head>
20
    <title>Apache Tomcat WebSocket Examples: Chat</title>
21
    <style type="text/css"><![CDATA[
22
        input#chat {
23
            width: 410px
24
        }
25
26
        #console-container {
27
            width: 400px;
28
        }
29
30
        #console {
31
            border: 1px solid #CCCCCC;
32
            border-right-color: #999999;
33
            border-bottom-color: #999999;
34
            height: 170px;
35
            overflow-y: scroll;
36
            padding: 5px;
37
            width: 100%;
38
        }
39
40
        #console p {
41
            padding: 0;
42
            margin: 0;
43
        }
44
    ]]></style>
45
    <script type="application/javascript"><![CDATA[
46
        var Chat = {};
47
48
        Chat.socket = null;
49
50
        Chat.connect = (function(host) {
51
            if ('WebSocket' in window) {
52
                Chat.socket = new WebSocket(host);
53
            } else if ('MozWebSocket' in window) {
54
                Chat.socket = new MozWebSocket(host);
55
            } else {
56
                Console.log('Error: WebSocket is not supported by this browser.');
57
                return;
58
            }
59
60
            Chat.socket.onopen = function () {
61
                Console.log('Info: WebSocket connection opened.');
62
                document.getElementById('chat').onkeydown = function(event) {
63
                    if (event.keyCode == 13) {
64
                        Chat.sendMessage();
65
                    }
66
                };
67
            };
68
69
            Chat.socket.onclose = function () {
70
                document.getElementById('chat').onkeydown = null;
71
                Console.log('Info: WebSocket closed.');
72
            };
73
74
            Chat.socket.onmessage = function (message) {
75
                Console.log(message.data);
76
            };
77
        });
78
79
        Chat.initialize = function() {
80
            if (window.location.protocol == 'http:') {
81
                Chat.connect('ws://' + window.location.host + '/examples/websocket/chat');
82
            } else {
83
                Chat.connect('wss://' + window.location.host + '/examples/websocket/chat');
84
            }
85
        };
86
87
        Chat.sendMessage = (function() {
88
            var message = document.getElementById('chat').value;
89
            if (message != '') {
90
                Chat.socket.send(message);
91
                document.getElementById('chat').value = '';
92
            }
93
        });
94
95
        var Console = {};
96
97
        Console.log = (function(message) {
98
            var console = document.getElementById('console');
99
            var p = document.createElement('p');
100
            p.style.wordWrap = 'break-word';
101
            p.innerHTML = message;
102
            console.appendChild(p);
103
            while (console.childNodes.length > 25) {
104
                console.removeChild(console.firstChild);
105
            }
106
            console.scrollTop = console.scrollHeight;
107
        });
108
109
        Chat.initialize();
110
111
112
        document.addEventListener("DOMContentLoaded", function() {
113
            // Remove elements with "noscript" class - <noscript> is not allowed in XHTML
114
            var noscripts = document.getElementsByClassName("noscript");
115
            for (var i = 0; i < noscripts.length; i++) {
116
                noscripts[i].parentNode.removeChild(noscripts[i]);
117
            }
118
        }, false);
119
120
    ]]></script>
121
</head>
122
<body>
123
<div class="noscript"><h2 style="color: #ff0000">Seems your browser doesn't support Javascript! Websockets rely on Javascript being enabled. Please enable
124
    Javascript and reload this page!</h2></div>
125
<div>
126
    <p>
127
        <input type="text" placeholder="type and press enter to chat" id="chat" />
128
    </p>
129
    <div id="console-container">
130
        <div id="console"/>
131
    </div>
132
</div>
133
</body>
134
</html>
135
native
(-)webapps/examples/websocket/echo.html (-160 lines)
Lines 1-160 Link Here
1
<!--
2
  Licensed to the Apache Software Foundation (ASF) under one or more
3
  contributor license agreements.  See the NOTICE file distributed with
4
  this work for additional information regarding copyright ownership.
5
  The ASF licenses this file to You under the Apache License, Version 2.0
6
  (the "License"); you may not use this file except in compliance with
7
  the License.  You may obtain a copy of the License at
8
9
      http://www.apache.org/licenses/LICENSE-2.0
10
11
  Unless required by applicable law or agreed to in writing, software
12
  distributed under the License is distributed on an "AS IS" BASIS,
13
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
  See the License for the specific language governing permissions and
15
  limitations under the License.
16
-->
17
<!DOCTYPE html>
18
<html>
19
<head>
20
    <title>Apache Tomcat WebSocket Examples: Echo</title>
21
    <style type="text/css">
22
        #connect-container {
23
            float: left;
24
            width: 400px
25
        }
26
27
        #connect-container div {
28
            padding: 5px;
29
        }
30
31
        #console-container {
32
            float: left;
33
            margin-left: 15px;
34
            width: 400px;
35
        }
36
37
        #console {
38
            border: 1px solid #CCCCCC;
39
            border-right-color: #999999;
40
            border-bottom-color: #999999;
41
            height: 170px;
42
            overflow-y: scroll;
43
            padding: 5px;
44
            width: 100%;
45
        }
46
47
        #console p {
48
            padding: 0;
49
            margin: 0;
50
        }
51
    </style>
52
    <script type="text/javascript">
53
        var ws = null;
54
55
        function setConnected(connected) {
56
            document.getElementById('connect').disabled = connected;
57
            document.getElementById('disconnect').disabled = !connected;
58
            document.getElementById('echo').disabled = !connected;
59
        }
60
61
        function connect() {
62
            var target = document.getElementById('target').value;
63
            if (target == '') {
64
                alert('Please select server side connection implementation.');
65
                return;
66
            }
67
            if ('WebSocket' in window) {
68
                ws = new WebSocket(target);
69
            } else if ('MozWebSocket' in window) {
70
                ws = new MozWebSocket(target);
71
            } else {
72
                alert('WebSocket is not supported by this browser.');
73
                return;
74
            }
75
            ws.onopen = function () {
76
                setConnected(true);
77
                log('Info: WebSocket connection opened.');
78
            };
79
            ws.onmessage = function (event) {
80
                log('Received: ' + event.data);
81
            };
82
            ws.onclose = function () {
83
                setConnected(false);
84
                log('Info: WebSocket connection closed.');
85
            };
86
        }
87
88
        function disconnect() {
89
            if (ws != null) {
90
                ws.close();
91
                ws = null;
92
            }
93
            setConnected(false);
94
        }
95
96
        function echo() {
97
            if (ws != null) {
98
                var message = document.getElementById('message').value;
99
                log('Sent: ' + message);
100
                ws.send(message);
101
            } else {
102
                alert('WebSocket connection not established, please connect.');
103
            }
104
        }
105
106
        function updateTarget(target) {
107
            if (window.location.protocol == 'http:') {
108
                document.getElementById('target').value = 'ws://' + window.location.host + target;
109
            } else {
110
                document.getElementById('target').value = 'wss://' + window.location.host + target;
111
            }
112
        }
113
114
        function log(message) {
115
            var console = document.getElementById('console');
116
            var p = document.createElement('p');
117
            p.style.wordWrap = 'break-word';
118
            p.appendChild(document.createTextNode(message));
119
            console.appendChild(p);
120
            while (console.childNodes.length > 25) {
121
                console.removeChild(console.firstChild);
122
            }
123
            console.scrollTop = console.scrollHeight;
124
        }
125
    </script>
126
</head>
127
<body>
128
<noscript><h2 style="color: #ff0000">Seems your browser doesn't support Javascript! Websockets rely on Javascript being enabled. Please enable
129
    Javascript and reload this page!</h2></noscript>
130
<div>
131
    <div id="connect-container">
132
        <div>
133
            <span>Connect to service implemented using:</span>
134
            <!-- echo example using new programmatic API on the server side -->
135
            <input id="radio1" type="radio" name="group1" value="/examples/websocket/echoProgrammatic"
136
                   onclick="updateTarget(this.value);"> <label for="radio1">programmatic API</label>
137
            <!-- echo example using new annotation API on the server side -->
138
            <input id="radio2" type="radio" name="group1" value="/examples/websocket/echoAnnotation"
139
                   onclick="updateTarget(this.value);"> <label for="radio2">annotation API</label>
140
        </div>
141
        <div>
142
            <input id="target" type="text" size="40" style="width: 350px"/>
143
        </div>
144
        <div>
145
            <button id="connect" onclick="connect();">Connect</button>
146
            <button id="disconnect" disabled="disabled" onclick="disconnect();">Disconnect</button>
147
        </div>
148
        <div>
149
            <textarea id="message" style="width: 350px">Here is a message!</textarea>
150
        </div>
151
        <div>
152
            <button id="echo" onclick="echo();" disabled="disabled">Echo message</button>
153
        </div>
154
    </div>
155
    <div id="console-container">
156
        <div id="console"></div>
157
    </div>
158
</div>
159
</body>
160
</html>
(-)webapps/examples/websocket/echo.xhtml (+170 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!--
3
  Licensed to the Apache Software Foundation (ASF) under one or more
4
  contributor license agreements.  See the NOTICE file distributed with
5
  this work for additional information regarding copyright ownership.
6
  The ASF licenses this file to You under the Apache License, Version 2.0
7
  (the "License"); you may not use this file except in compliance with
8
  the License.  You may obtain a copy of the License at
9
10
      http://www.apache.org/licenses/LICENSE-2.0
11
12
  Unless required by applicable law or agreed to in writing, software
13
  distributed under the License is distributed on an "AS IS" BASIS,
14
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
  See the License for the specific language governing permissions and
16
  limitations under the License.
17
-->
18
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
19
<head>
20
    <title>Apache Tomcat WebSocket Examples: Echo</title>
21
    <style type="text/css"><![CDATA[
22
        #connect-container {
23
            float: left;
24
            width: 400px
25
        }
26
27
        #connect-container div {
28
            padding: 5px;
29
        }
30
31
        #console-container {
32
            float: left;
33
            margin-left: 15px;
34
            width: 400px;
35
        }
36
37
        #console {
38
            border: 1px solid #CCCCCC;
39
            border-right-color: #999999;
40
            border-bottom-color: #999999;
41
            height: 170px;
42
            overflow-y: scroll;
43
            padding: 5px;
44
            width: 100%;
45
        }
46
47
        #console p {
48
            padding: 0;
49
            margin: 0;
50
        }
51
    ]]></style>
52
    <script type="application/javascript"><![CDATA[
53
        var ws = null;
54
55
        function setConnected(connected) {
56
            document.getElementById('connect').disabled = connected;
57
            document.getElementById('disconnect').disabled = !connected;
58
            document.getElementById('echo').disabled = !connected;
59
        }
60
61
        function connect() {
62
            var target = document.getElementById('target').value;
63
            if (target == '') {
64
                alert('Please select server side connection implementation.');
65
                return;
66
            }
67
            if ('WebSocket' in window) {
68
                ws = new WebSocket(target);
69
            } else if ('MozWebSocket' in window) {
70
                ws = new MozWebSocket(target);
71
            } else {
72
                alert('WebSocket is not supported by this browser.');
73
                return;
74
            }
75
            ws.onopen = function () {
76
                setConnected(true);
77
                log('Info: WebSocket connection opened.');
78
            };
79
            ws.onmessage = function (event) {
80
                log('Received: ' + event.data);
81
            };
82
            ws.onclose = function () {
83
                setConnected(false);
84
                log('Info: WebSocket connection closed.');
85
            };
86
        }
87
88
        function disconnect() {
89
            if (ws != null) {
90
                ws.close();
91
                ws = null;
92
            }
93
            setConnected(false);
94
        }
95
96
        function echo() {
97
            if (ws != null) {
98
                var message = document.getElementById('message').value;
99
                log('Sent: ' + message);
100
                ws.send(message);
101
            } else {
102
                alert('WebSocket connection not established, please connect.');
103
            }
104
        }
105
106
        function updateTarget(target) {
107
            if (window.location.protocol == 'http:') {
108
                document.getElementById('target').value = 'ws://' + window.location.host + target;
109
            } else {
110
                document.getElementById('target').value = 'wss://' + window.location.host + target;
111
            }
112
        }
113
114
        function log(message) {
115
            var console = document.getElementById('console');
116
            var p = document.createElement('p');
117
            p.style.wordWrap = 'break-word';
118
            p.appendChild(document.createTextNode(message));
119
            console.appendChild(p);
120
            while (console.childNodes.length > 25) {
121
                console.removeChild(console.firstChild);
122
            }
123
            console.scrollTop = console.scrollHeight;
124
        }
125
126
127
        document.addEventListener("DOMContentLoaded", function() {
128
            // Remove elements with "noscript" class - <noscript> is not allowed in XHTML
129
            var noscripts = document.getElementsByClassName("noscript");
130
            for (var i = 0; i < noscripts.length; i++) {
131
                noscripts[i].parentNode.removeChild(noscripts[i]);
132
            }
133
        }, false);
134
    ]]></script>
135
</head>
136
<body>
137
<div class="noscript"><h2 style="color: #ff0000">Seems your browser doesn't support Javascript! Websockets rely on Javascript being enabled. Please enable
138
    Javascript and reload this page!</h2></div>
139
<div>
140
    <div id="connect-container">
141
        <div>
142
            <span>Connect to service implemented using:</span>
143
            <!-- echo example using new programmatic API on the server side -->
144
            <input id="radio1" type="radio" name="group1" value="/examples/websocket/echoProgrammatic"
145
                   onclick="updateTarget(this.value);"/> <label for="radio1">programmatic API</label>
146
            <!-- echo example using new annotation API on the server side -->
147
            <input id="radio2" type="radio" name="group1" value="/examples/websocket/echoAnnotation"
148
                   onclick="updateTarget(this.value);"/> <label for="radio2">annotation API</label>
149
        </div>
150
        <div>
151
            <input id="target" type="text" size="40" style="width: 350px"/>
152
        </div>
153
        <div>
154
            <button id="connect" onclick="connect();">Connect</button>
155
            <button id="disconnect" disabled="disabled" onclick="disconnect();">Disconnect</button>
156
        </div>
157
        <div>
158
            <textarea id="message" style="width: 350px">Here is a message!</textarea>
159
        </div>
160
        <div>
161
            <button id="echo" onclick="echo();" disabled="disabled">Echo message</button>
162
        </div>
163
    </div>
164
    <div id="console-container">
165
        <div id="console"/>
166
    </div>
167
</div>
168
</body>
169
</html>
170
native
(-)webapps/examples/websocket/index.html (-31 lines)
Lines 1-31 Link Here
1
<!--
2
  Licensed to the Apache Software Foundation (ASF) under one or more
3
  contributor license agreements.  See the NOTICE file distributed with
4
  this work for additional information regarding copyright ownership.
5
  The ASF licenses this file to You under the Apache License, Version 2.0
6
  (the "License"); you may not use this file except in compliance with
7
  the License.  You may obtain a copy of the License at
8
9
      http://www.apache.org/licenses/LICENSE-2.0
10
11
  Unless required by applicable law or agreed to in writing, software
12
  distributed under the License is distributed on an "AS IS" BASIS,
13
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
  See the License for the specific language governing permissions and
15
  limitations under the License.
16
-->
17
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
18
<html>
19
<head>
20
    <meta http-equiv=Content-Type content="text/html">
21
    <title>Apache Tomcat WebSocket Examples</title>
22
</head>
23
<body>
24
<h3>Apache Tomcat WebSocket Examples</h3>
25
<ul>
26
    <li><a href="echo.html">Echo example</a></li>
27
    <li><a href="chat.html">Chat example</a></li>
28
    <li><a href="snake.html">Multiplayer snake example</a></li>
29
</ul>
30
</body>
31
</html>
(-)webapps/examples/websocket/index.xhtml (+31 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!--
3
  Licensed to the Apache Software Foundation (ASF) under one or more
4
  contributor license agreements.  See the NOTICE file distributed with
5
  this work for additional information regarding copyright ownership.
6
  The ASF licenses this file to You under the Apache License, Version 2.0
7
  (the "License"); you may not use this file except in compliance with
8
  the License.  You may obtain a copy of the License at
9
10
      http://www.apache.org/licenses/LICENSE-2.0
11
12
  Unless required by applicable law or agreed to in writing, software
13
  distributed under the License is distributed on an "AS IS" BASIS,
14
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
  See the License for the specific language governing permissions and
16
  limitations under the License.
17
-->
18
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
19
<head>
20
    <title>Apache Tomcat WebSocket Examples</title>
21
</head>
22
<body>
23
<h1>Apache Tomcat WebSocket Examples</h1>
24
<ul>
25
    <li><a href="echo.xhtml">Echo example</a></li>
26
    <li><a href="chat.xhtml">Chat example</a></li>
27
    <li><a href="snake.xhtml">Multiplayer snake example</a></li>
28
</ul>
29
</body>
30
</html>
31
native
(-)webapps/examples/websocket/snake.html (-258 lines)
Lines 1-258 Link Here
1
<!--
2
  Licensed to the Apache Software Foundation (ASF) under one or more
3
  contributor license agreements.  See the NOTICE file distributed with
4
  this work for additional information regarding copyright ownership.
5
  The ASF licenses this file to You under the Apache License, Version 2.0
6
  (the "License"); you may not use this file except in compliance with
7
  the License.  You may obtain a copy of the License at
8
9
      http://www.apache.org/licenses/LICENSE-2.0
10
11
  Unless required by applicable law or agreed to in writing, software
12
  distributed under the License is distributed on an "AS IS" BASIS,
13
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
  See the License for the specific language governing permissions and
15
  limitations under the License.
16
-->
17
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
18
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
19
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
20
<head>
21
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
22
    <title>Apache Tomcat WebSocket Examples: Multiplayer Snake</title>
23
    <style type="text/css">
24
        #playground {
25
            width: 640px;
26
            height: 480px;
27
            background-color: #000;
28
        }
29
30
        #console-container {
31
            float: left;
32
            margin-left: 15px;
33
            width: 300px;
34
        }
35
36
        #console {
37
            border: 1px solid #CCCCCC;
38
            border-right-color: #999999;
39
            border-bottom-color: #999999;
40
            height: 480px;
41
            overflow-y: scroll;
42
            padding-left: 5px;
43
            padding-right: 5px;
44
            width: 100%;
45
        }
46
47
        #console p {
48
            padding: 0;
49
            margin: 0;
50
        }
51
    </style>
52
</head>
53
<body>
54
    <noscript><h2 style="color: #ff0000">Seems your browser doesn't support Javascript! Websockets rely on Javascript being enabled. Please enable
55
    Javascript and reload this page!</h2></noscript>
56
    <div style="float: left">
57
        <canvas id="playground" width="640" height="480"></canvas>
58
    </div>
59
    <div id="console-container">
60
        <div id="console"></div>
61
    </div>
62
    <script type="text/javascript">
63
64
        var Game = {};
65
66
        Game.fps = 30;
67
        Game.socket = null;
68
        Game.nextFrame = null;
69
        Game.interval = null;
70
        Game.direction = 'none';
71
        Game.gridSize = 10;
72
73
        function Snake() {
74
            this.snakeBody = [];
75
            this.color = null;
76
        }
77
78
        Snake.prototype.draw = function(context) {
79
            for (var id in this.snakeBody) {
80
                context.fillStyle = this.color;
81
                context.fillRect(this.snakeBody[id].x, this.snakeBody[id].y, Game.gridSize, Game.gridSize);
82
            }
83
        };
84
85
        Game.initialize = function() {
86
            this.entities = [];
87
            canvas = document.getElementById('playground');
88
            if (!canvas.getContext) {
89
                Console.log('Error: 2d canvas not supported by this browser.');
90
                return;
91
            }
92
            this.context = canvas.getContext('2d');
93
            window.addEventListener('keydown', function (e) {
94
                var code = e.keyCode;
95
                if (code > 36 && code < 41) {
96
                    switch (code) {
97
                        case 37:
98
                            if (Game.direction != 'east') Game.setDirection('west');
99
                            break;
100
                        case 38:
101
                            if (Game.direction != 'south') Game.setDirection('north');
102
                            break;
103
                        case 39:
104
                            if (Game.direction != 'west') Game.setDirection('east');
105
                            break;
106
                        case 40:
107
                            if (Game.direction != 'north') Game.setDirection('south');
108
                            break;
109
                    }
110
                }
111
            }, false);
112
            if (window.location.protocol == 'http:') {
113
                Game.connect('ws://' + window.location.host + '/examples/websocket/snake');
114
            } else {
115
                Game.connect('wss://' + window.location.host + '/examples/websocket/snake');
116
            }
117
        };
118
119
        Game.setDirection  = function(direction) {
120
            Game.direction = direction;
121
            Game.socket.send(direction);
122
            Console.log('Sent: Direction ' + direction);
123
        };
124
125
        Game.startGameLoop = function() {
126
            if (window.webkitRequestAnimationFrame) {
127
                Game.nextFrame = function () {
128
                    webkitRequestAnimationFrame(Game.run);
129
                };
130
            } else if (window.mozRequestAnimationFrame) {
131
                Game.nextFrame = function () {
132
                    mozRequestAnimationFrame(Game.run);
133
                };
134
            } else {
135
                Game.interval = setInterval(Game.run, 1000 / Game.fps);
136
            }
137
            if (Game.nextFrame != null) {
138
                Game.nextFrame();
139
            }
140
        };
141
142
        Game.stopGameLoop = function () {
143
            Game.nextFrame = null;
144
            if (Game.interval != null) {
145
                clearInterval(Game.interval);
146
            }
147
        };
148
149
        Game.draw = function() {
150
            this.context.clearRect(0, 0, 640, 480);
151
            for (var id in this.entities) {
152
                this.entities[id].draw(this.context);
153
            }
154
        };
155
156
        Game.addSnake = function(id, color) {
157
            Game.entities[id] = new Snake();
158
            Game.entities[id].color = color;
159
        };
160
161
        Game.updateSnake = function(id, snakeBody) {
162
            if (typeof Game.entities[id] != "undefined") {
163
                Game.entities[id].snakeBody = snakeBody;
164
            }
165
        };
166
167
        Game.removeSnake = function(id) {
168
            Game.entities[id] = null;
169
            // Force GC.
170
            delete Game.entities[id];
171
        };
172
173
        Game.run = (function() {
174
            var skipTicks = 1000 / Game.fps, nextGameTick = (new Date).getTime();
175
176
            return function() {
177
                while ((new Date).getTime() > nextGameTick) {
178
                    nextGameTick += skipTicks;
179
                }
180
                Game.draw();
181
                if (Game.nextFrame != null) {
182
                    Game.nextFrame();
183
                }
184
            };
185
        })();
186
187
        Game.connect = (function(host) {
188
            if ('WebSocket' in window) {
189
                Game.socket = new WebSocket(host);
190
            } else if ('MozWebSocket' in window) {
191
                Game.socket = new MozWebSocket(host);
192
            } else {
193
                Console.log('Error: WebSocket is not supported by this browser.');
194
                return;
195
            }
196
197
            Game.socket.onopen = function () {
198
                // Socket open.. start the game loop.
199
                Console.log('Info: WebSocket connection opened.');
200
                Console.log('Info: Press an arrow key to begin.');
201
                Game.startGameLoop();
202
                setInterval(function() {
203
                    // Prevent server read timeout.
204
                    Game.socket.send('ping');
205
                }, 5000);
206
            };
207
208
            Game.socket.onclose = function () {
209
                Console.log('Info: WebSocket closed.');
210
                Game.stopGameLoop();
211
            };
212
213
            Game.socket.onmessage = function (message) {
214
                // _Potential_ security hole, consider using json lib to parse data in production.
215
                var packet = eval('(' + message.data + ')');
216
                switch (packet.type) {
217
                    case 'update':
218
                        for (var i = 0; i < packet.data.length; i++) {
219
                            Game.updateSnake(packet.data[i].id, packet.data[i].body);
220
                        }
221
                        break;
222
                    case 'join':
223
                        for (var j = 0; j < packet.data.length; j++) {
224
                            Game.addSnake(packet.data[j].id, packet.data[j].color);
225
                        }
226
                        break;
227
                    case 'leave':
228
                        Game.removeSnake(packet.id);
229
                        break;
230
                    case 'dead':
231
                        Console.log('Info: Your snake is dead, bad luck!');
232
                        Game.direction = 'none';
233
                        break;
234
                    case 'kill':
235
                        Console.log('Info: Head shot!');
236
                        break;
237
                }
238
            };
239
        });
240
241
        var Console = {};
242
243
        Console.log = (function(message) {
244
            var console = document.getElementById('console');
245
            var p = document.createElement('p');
246
            p.style.wordWrap = 'break-word';
247
            p.innerHTML = message;
248
            console.appendChild(p);
249
            while (console.childNodes.length > 25) {
250
                console.removeChild(console.firstChild);
251
            }
252
            console.scrollTop = console.scrollHeight;
253
        });
254
255
        Game.initialize();
256
    </script>
257
</body>
258
</html>
(-)webapps/examples/websocket/snake.xhtml (+267 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!--
3
  Licensed to the Apache Software Foundation (ASF) under one or more
4
  contributor license agreements.  See the NOTICE file distributed with
5
  this work for additional information regarding copyright ownership.
6
  The ASF licenses this file to You under the Apache License, Version 2.0
7
  (the "License"); you may not use this file except in compliance with
8
  the License.  You may obtain a copy of the License at
9
10
      http://www.apache.org/licenses/LICENSE-2.0
11
12
  Unless required by applicable law or agreed to in writing, software
13
  distributed under the License is distributed on an "AS IS" BASIS,
14
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
  See the License for the specific language governing permissions and
16
  limitations under the License.
17
-->
18
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
19
<head>
20
    <title>Apache Tomcat WebSocket Examples: Multiplayer Snake</title>
21
    <style type="text/css"><![CDATA[
22
        #playground {
23
            width: 640px;
24
            height: 480px;
25
            background-color: #000;
26
        }
27
28
        #console-container {
29
            float: left;
30
            margin-left: 15px;
31
            width: 300px;
32
        }
33
34
        #console {
35
            border: 1px solid #CCCCCC;
36
            border-right-color: #999999;
37
            border-bottom-color: #999999;
38
            height: 480px;
39
            overflow-y: scroll;
40
            padding-left: 5px;
41
            padding-right: 5px;
42
            width: 100%;
43
        }
44
45
        #console p {
46
            padding: 0;
47
            margin: 0;
48
        }
49
    ]]></style>
50
</head>
51
<body>
52
    <div class="noscript"><h2 style="color: #ff0000">Seems your browser doesn't support Javascript! Websockets rely on Javascript being enabled. Please enable
53
    Javascript and reload this page!</h2></div>
54
    <div style="float: left">
55
        <canvas id="playground" width="640" height="480"/>
56
    </div>
57
    <div id="console-container">
58
        <div id="console"/>
59
    </div>
60
    <script type="application/javascript"><![CDATA[
61
62
        var Game = {};
63
64
        Game.fps = 30;
65
        Game.socket = null;
66
        Game.nextFrame = null;
67
        Game.interval = null;
68
        Game.direction = 'none';
69
        Game.gridSize = 10;
70
71
        function Snake() {
72
            this.snakeBody = [];
73
            this.color = null;
74
        }
75
76
        Snake.prototype.draw = function(context) {
77
            for (var id in this.snakeBody) {
78
                context.fillStyle = this.color;
79
                context.fillRect(this.snakeBody[id].x, this.snakeBody[id].y, Game.gridSize, Game.gridSize);
80
            }
81
        };
82
83
        Game.initialize = function() {
84
            this.entities = [];
85
            canvas = document.getElementById('playground');
86
            if (!canvas.getContext) {
87
                Console.log('Error: 2d canvas not supported by this browser.');
88
                return;
89
            }
90
            this.context = canvas.getContext('2d');
91
            window.addEventListener('keydown', function (e) {
92
                var code = e.keyCode;
93
                if (code > 36 && code < 41) {
94
                    switch (code) {
95
                        case 37:
96
                            if (Game.direction != 'east') Game.setDirection('west');
97
                            break;
98
                        case 38:
99
                            if (Game.direction != 'south') Game.setDirection('north');
100
                            break;
101
                        case 39:
102
                            if (Game.direction != 'west') Game.setDirection('east');
103
                            break;
104
                        case 40:
105
                            if (Game.direction != 'north') Game.setDirection('south');
106
                            break;
107
                    }
108
                }
109
            }, false);
110
            if (window.location.protocol == 'http:') {
111
                Game.connect('ws://' + window.location.host + '/examples/websocket/snake');
112
            } else {
113
                Game.connect('wss://' + window.location.host + '/examples/websocket/snake');
114
            }
115
        };
116
117
        Game.setDirection  = function(direction) {
118
            Game.direction = direction;
119
            Game.socket.send(direction);
120
            Console.log('Sent: Direction ' + direction);
121
        };
122
123
        Game.startGameLoop = function() {
124
            if (window.webkitRequestAnimationFrame) {
125
                Game.nextFrame = function () {
126
                    webkitRequestAnimationFrame(Game.run);
127
                };
128
            } else if (window.mozRequestAnimationFrame) {
129
                Game.nextFrame = function () {
130
                    mozRequestAnimationFrame(Game.run);
131
                };
132
            } else {
133
                Game.interval = setInterval(Game.run, 1000 / Game.fps);
134
            }
135
            if (Game.nextFrame != null) {
136
                Game.nextFrame();
137
            }
138
        };
139
140
        Game.stopGameLoop = function () {
141
            Game.nextFrame = null;
142
            if (Game.interval != null) {
143
                clearInterval(Game.interval);
144
            }
145
        };
146
147
        Game.draw = function() {
148
            this.context.clearRect(0, 0, 640, 480);
149
            for (var id in this.entities) {
150
                this.entities[id].draw(this.context);
151
            }
152
        };
153
154
        Game.addSnake = function(id, color) {
155
            Game.entities[id] = new Snake();
156
            Game.entities[id].color = color;
157
        };
158
159
        Game.updateSnake = function(id, snakeBody) {
160
            if (typeof Game.entities[id] != "undefined") {
161
                Game.entities[id].snakeBody = snakeBody;
162
            }
163
        };
164
165
        Game.removeSnake = function(id) {
166
            Game.entities[id] = null;
167
            // Force GC.
168
            delete Game.entities[id];
169
        };
170
171
        Game.run = (function() {
172
            var skipTicks = 1000 / Game.fps, nextGameTick = (new Date).getTime();
173
174
            return function() {
175
                while ((new Date).getTime() > nextGameTick) {
176
                    nextGameTick += skipTicks;
177
                }
178
                Game.draw();
179
                if (Game.nextFrame != null) {
180
                    Game.nextFrame();
181
                }
182
            };
183
        })();
184
185
        Game.connect = (function(host) {
186
            if ('WebSocket' in window) {
187
                Game.socket = new WebSocket(host);
188
            } else if ('MozWebSocket' in window) {
189
                Game.socket = new MozWebSocket(host);
190
            } else {
191
                Console.log('Error: WebSocket is not supported by this browser.');
192
                return;
193
            }
194
195
            Game.socket.onopen = function () {
196
                // Socket open.. start the game loop.
197
                Console.log('Info: WebSocket connection opened.');
198
                Console.log('Info: Press an arrow key to begin.');
199
                Game.startGameLoop();
200
                setInterval(function() {
201
                    // Prevent server read timeout.
202
                    Game.socket.send('ping');
203
                }, 5000);
204
            };
205
206
            Game.socket.onclose = function () {
207
                Console.log('Info: WebSocket closed.');
208
                Game.stopGameLoop();
209
            };
210
211
            Game.socket.onmessage = function (message) {
212
                // _Potential_ security hole, consider using json lib to parse data in production.
213
                var packet = eval('(' + message.data + ')');
214
                switch (packet.type) {
215
                    case 'update':
216
                        for (var i = 0; i < packet.data.length; i++) {
217
                            Game.updateSnake(packet.data[i].id, packet.data[i].body);
218
                        }
219
                        break;
220
                    case 'join':
221
                        for (var j = 0; j < packet.data.length; j++) {
222
                            Game.addSnake(packet.data[j].id, packet.data[j].color);
223
                        }
224
                        break;
225
                    case 'leave':
226
                        Game.removeSnake(packet.id);
227
                        break;
228
                    case 'dead':
229
                        Console.log('Info: Your snake is dead, bad luck!');
230
                        Game.direction = 'none';
231
                        break;
232
                    case 'kill':
233
                        Console.log('Info: Head shot!');
234
                        break;
235
                }
236
            };
237
        });
238
239
        var Console = {};
240
241
        Console.log = (function(message) {
242
            var console = document.getElementById('console');
243
            var p = document.createElement('p');
244
            p.style.wordWrap = 'break-word';
245
            p.innerHTML = message;
246
            console.appendChild(p);
247
            while (console.childNodes.length > 25) {
248
                console.removeChild(console.firstChild);
249
            }
250
            console.scrollTop = console.scrollHeight;
251
        });
252
253
        Game.initialize();
254
255
256
        document.addEventListener("DOMContentLoaded", function() {
257
            // Remove elements with "noscript" class - <noscript> is not allowed in XHTML
258
            var noscripts = document.getElementsByClassName("noscript");
259
            for (var i = 0; i < noscripts.length; i++) {
260
                noscripts[i].parentNode.removeChild(noscripts[i]);
261
            }
262
        }, false);
263
264
        ]]></script>
265
</body>
266
</html>
267
native

Return to bug 55383