This commit is contained in:
2024-11-30 19:03:49 +08:00
commit 1e6763c160
3806 changed files with 737676 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<%@page session="false" import="java.util.Date,java.text.SimpleDateFormat"%>
Output from async1.jsp
Type is <%=request.getDispatcherType()%>
<%
System.out.println("Inside Async 1");
if (request.isAsyncStarted()) {
request.getAsyncContext().complete();
}
Date date = new Date(System.currentTimeMillis());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
%>
Completed async request at <%=sdf.format(date)%>

View File

@@ -0,0 +1,25 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<%@page session="false" import="java.util.Date,java.text.SimpleDateFormat"%>
Output from async3.jsp
Type is <%=request.getDispatcherType()%>
<%
Date date = new Date(System.currentTimeMillis());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
%>
Completed async 3 request at <%=sdf.format(date)%>

View File

@@ -0,0 +1,69 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<%@page session="false"%>
<pre>
Use cases:
1. Simple dispatch
- servlet does startAsync()
- background thread calls ctx.dispatch()
<a href="<%=response.encodeURL("/examples/async/async0")%>"> Async 0 </a>
2. Simple dispatch
- servlet does startAsync()
- background thread calls dispatch(/path/to/jsp)
<a href="<%=response.encodeURL("/examples/async/async1")%>"> Async 1 </a>
3. Simple dispatch
- servlet does startAsync()
- background thread calls writes and calls complete()
<a href="<%=response.encodeURL("/examples/async/async2")%>"> Async 2 </a>
4. Simple dispatch
- servlet does a startAsync()
- servlet calls dispatch(/path/to/jsp)
- servlet calls complete()
<a href="<%=response.encodeURL("/examples/async/async3")%>"> Async 3 </a>
3. Timeout s1
- servlet does a startAsync()
- servlet does a setAsyncTimeout
- returns - waits for timeout to happen should return error page
4. Timeout s2
- servlet does a startAsync()
- servlet does a setAsyncTimeout
- servlet does a addAsyncListener
- returns - waits for timeout to happen and listener invoked
5. Dispatch to asyncSupported=false servlet
- servlet1 does a startAsync()
- servlet1 dispatches to dispatch(/servlet2)
- the container calls complete() after servlet2 is complete
- TODO
6. Chained dispatch
- servlet1 does a startAsync
- servlet1 does a dispatch to servlet2 (asyncsupported=true)
- servlet2 does a dispatch to servlet3 (asyncsupported=true)
- servlet3 does a dispatch to servlet4 (asyncsupported=false)
7. Stock ticker
<a href="<%=response.encodeURL("/examples/async/stockticker")%>"> StockTicker </a>
</pre>

View File

@@ -0,0 +1,94 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<%@page contentType="text/html; charset=UTF-8" %>
<HTML>
<HEAD><TITLE>
Calendar: A JSP APPLICATION
</TITLE></HEAD>
<BODY BGCOLOR="white">
<%@ page language="java" import="cal.*" %>
<jsp:useBean id="table" scope="session" class="cal.TableBean" />
<%
table.processRequest(request);
if (table.getProcessError() == false) {
%>
<!-- html table goes here -->
<CENTER>
<TABLE WIDTH=60% BGCOLOR=yellow CELLPADDING=15>
<TR>
<TD ALIGN=CENTER> <A HREF=cal1.jsp?date=prev> prev </A>
<TD ALIGN=CENTER> Calendar:<%= table.getDate() %></TD>
<TD ALIGN=CENTER> <A HREF=cal1.jsp?date=next> next </A>
</TR>
</TABLE>
<!-- the main table -->
<TABLE WIDTH=60% BGCOLOR=lightblue BORDER=1 CELLPADDING=10>
<TR>
<TH> Time </TH>
<TH> Appointment </TH>
</TR>
<FORM METHOD=POST ACTION=cal1.jsp>
<%
for(int i=0; i<table.getEntries().getRows(); i++) {
cal.Entry entr = table.getEntries().getEntry(i);
%>
<TR>
<TD>
<A HREF=cal2.jsp?time=<%= entr.getHour() %>>
<%= entr.getHour() %> </A>
</TD>
<TD BGCOLOR=<%= entr.getColor() %>>
<% out.print(util.HTMLFilter.filter(entr.getDescription())); %>
</TD>
</TR>
<%
}
%>
</FORM>
</TABLE>
<BR>
<!-- footer -->
<TABLE WIDTH=60% BGCOLOR=yellow CELLPADDING=15>
<TR>
<TD ALIGN=CENTER> <% out.print(util.HTMLFilter.filter(table.getName())); %> :
<% out.print(util.HTMLFilter.filter(table.getEmail())); %> </TD>
</TR>
</TABLE>
</CENTER>
<%
} else {
%>
<font size=5>
You must enter your name and email address correctly.
</font>
<%
}
%>
</BODY>
</HTML>

View File

@@ -0,0 +1,45 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<%@page contentType="text/html; charset=UTF-8" %>
<HTML>
<HEAD><TITLE>
Calendar: A JSP APPLICATION
</TITLE></HEAD>
<BODY BGCOLOR="white">
<jsp:useBean id="table" scope="session" class="cal.TableBean" />
<%
String time = request.getParameter ("time");
%>
<FONT SIZE=5> Please add the following event:
<BR> <h3> Date <%= table.getDate() %>
<BR> Time <%= util.HTMLFilter.filter(time) %> </h3>
</FONT>
<FORM METHOD=POST ACTION=cal1.jsp>
<BR>
<BR> <INPUT NAME="date" TYPE=HIDDEN VALUE="current">
<BR> <INPUT NAME="time" TYPE=HIDDEN VALUE="<%= util.HTMLFilter.filter(time) %>">
<BR> <h2> Description of the event <INPUT NAME="description" TYPE=TEXT SIZE=20> </h2>
<BR> <INPUT TYPE=SUBMIT VALUE="submit">
</FORM>
</BODY>
</HTML>

View File

@@ -0,0 +1,43 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="login.html"><img src="../images/execute.gif" align="right" border="0"></a><a href="../index.html"><img src="../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h2> Source Code for Calendar Example. <br>
<h3><a href="cal1.jsp.html">cal1.jsp<font color="#0000FF"></a>
</font> </h3>
<h3><a href="cal2.jsp.html">cal2.jsp<font color="#0000FF"></a>
</font> </h3>
<br>
<h2> Beans.
<h3><a href="TableBean.java.html">TableBean<font color="#0000FF"></a>
</font> </h3>
<h3><a href="Entries.java.html">Entries<font color="#0000FF"></a>
</font> </h3>
<h3><a href="Entry.java.html">Entry<font color="#0000FF"></a>
</font> </h3>
</body>
</html>

View File

@@ -0,0 +1,47 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title> Login page for the calendar. </title>
</head>
<body bgcolor="white">
<center>
<font size=7 color="red"> Please Enter the following information: </font>
<br>
<form method=GET action=cal1.jsp>
<font size=5> Name <input type=text name="name" size=20>
</font>
<br>
<font size=5> Email <input type=text name="email" size=20>
</font>
<br>
<input type=submit name=action value="Submit">
</form>
<hr>
<font size=3 color="red"> Note: This application does not implement the complete
functionality of a typical calendar application. It demonstrates a way JSP can
be used with html tables and forms.</font>
</center>
</body>
</html>

View File

@@ -0,0 +1,56 @@
<HTML>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<HEAD>
<title>
checkbox.CheckTest Bean Properties
</title>
<BODY BGCOLOR="white">
<H2>
checkbox.CheckTest Bean Properties
</H2>
<HR>
<DL>
<DT>public class <B>CheckTest</B><DT>extends Object</DL>
<P>
<HR>
<P>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0">
<TR BGCOLOR="#EEEEFF">
<TD COLSPAN=3><FONT SIZE="+2">
<B>Properties Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white">
<td align="right" valign="top" width="1%">
<FONT SIZE="-1">
String
</FONT></TD>
<TD><B>CheckTest:fruit</B>
<BR>
</TD>
<td width="1%">
<FONT SIZE="-1">
Multi
</FONT></TD>
</TABLE>
<HR>
</BODY>
</HTML>

View File

@@ -0,0 +1,38 @@
<HTML>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<BODY bgcolor="white">
<FORM TYPE=POST ACTION=checkresult.jsp>
<BR>
<font size=5 color="red">
Check all Favorite fruits: <br>
<input TYPE=checkbox name=fruit VALUE=apples> Apples <BR>
<input TYPE=checkbox name=fruit VALUE=grapes> Grapes <BR>
<input TYPE=checkbox name=fruit VALUE=oranges> Oranges <BR>
<input TYPE=checkbox name=fruit VALUE=melons> Melons <BR>
<br> <INPUT TYPE=submit name=submit Value="Submit">
</font>
</FORM>
</BODY>
</HTML>

View File

@@ -0,0 +1,63 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<html>
<body bgcolor="white">
<font size=5 color="red">
<%! String[] fruits; %>
<jsp:useBean id="foo" scope="page" class="checkbox.CheckTest" />
<jsp:setProperty name="foo" property="fruit" param="fruit" />
<hr>
The checked fruits (got using request) are: <br>
<%
fruits = request.getParameterValues("fruit");
%>
<ul>
<%
if (fruits != null) {
for (int i = 0; i < fruits.length; i++) {
%>
<li>
<%
out.println (util.HTMLFilter.filter(fruits[i]));
}
} else out.println ("none selected");
%>
</ul>
<br>
<hr>
The checked fruits (got using beans) are <br>
<%
fruits = foo.getFruit();
%>
<ul>
<%
if (!fruits[0].equals("1")) {
for (int i = 0; i < fruits.length; i++) {
%>
<li>
<%
out.println (util.HTMLFilter.filter(fruits[i]));
}
} else out.println ("none selected");
%>
</ul>
</font>
</body>
</html>

View File

@@ -0,0 +1,34 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="check.html"><img src="../images/execute.gif" align="right" border="0"></a><a href="../index.html"><img src="../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="checkresult.jsp.html">Source Code for Checkbox Example<font color="#0000FF"></a>
</font> </h3>
<h3><a href="CheckTest.html">Property Sheet for CheckTest
<font color="#0000FF"></a> </font> </h3>
</body>
</html>

View File

@@ -0,0 +1,116 @@
<HTML>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<HEAD>
<title>
colors.ColorGameBean Bean Properties
</title>
<BODY BGCOLOR="white">
<H2>
colors.ColorGameBean Bean Properties
</H2>
<HR>
<DL>
<DT>public class <B>ColorGameBean</B><DT>extends Object</DL>
<P>
<HR>
<P>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0">
<TR BGCOLOR="#EEEEFF">
<TD COLSPAN=3><FONT SIZE="+2">
<B>Properties Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white">
<td align="right" valign="top" width="1%">
<FONT SIZE="-1">
String
</FONT></TD>
<TD><B>ColorGameBean:color2</B>
<BR>
</TD>
<td width="1%">
<FONT SIZE="-1">
Single
</FONT></TD>
<TR BGCOLOR="white">
<td align="right" valign="top" width="1%">
<FONT SIZE="-1">
String
</FONT></TD>
<TD><B>ColorGameBean:color1</B>
<BR>
</TD>
<td width="1%">
<FONT SIZE="-1">
Single
</FONT></TD>
<TR BGCOLOR="white">
<td align="right" valign="top" width="1%">
<FONT SIZE="-1">
int
</FONT></TD>
<TD><B>ColorGameBean:attempts</B>
<BR>
</TD>
<td width="1%">
<FONT SIZE="-1">
Single
</FONT></TD>
<TR BGCOLOR="white">
<td align="right" valign="top" width="1%">
<FONT SIZE="-1">
boolean
</FONT></TD>
<TD><B>ColorGameBean:hint</B>
<BR>
</TD>
<td width="1%">
<FONT SIZE="-1">
Single
</FONT></TD>
<TR BGCOLOR="white">
<td align="right" valign="top" width="1%">
<FONT SIZE="-1">
boolean
</FONT></TD>
<TD><B>ColorGameBean:success</B>
<BR>
</TD>
<td width="1%">
<FONT SIZE="-1">
Single
</FONT></TD>
<TR BGCOLOR="white">
<td align="right" valign="top" width="1%">
<FONT SIZE="-1">
boolean
</FONT></TD>
<TD><B>ColorGameBean:hintTaken</B>
<BR>
</TD>
<td width="1%">
<FONT SIZE="-1">
Single
</FONT></TD>
</TABLE>
<HR>
</BODY>
</HTML>

View File

@@ -0,0 +1,34 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="colors.html"><img src="../images/execute.gif" align="right" border="0"></a><a href="../index.html"><img src="../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="colrs.jsp.html">Source Code for Color Example<font color="#0000FF"></a>
</font> </h3>
<h3><a href="ColorGameBean.html">Property Sheet for ColorGameBean
<font color="#0000FF"></a> </font> </h3>
</body>
</html>

View File

@@ -0,0 +1,47 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<body bgcolor= white>
<font size=6 color=red>
<hr>
This web page is an example using JSP and BEANs.
<p>
Guess my favorite two colors
<p> If you fail to guess both of them - you get yellow on red.
<p> If you guess one of them right, either your foreground or
your background will change to the color that was guessed right.
<p> Guess them both right and your browser foreground/background
will change to my two favorite colors to display this page.
<hr>
<form method=GET action=colrs.jsp>
Color #1: <input type=text name= color1 size=16>
<br>
Color #2: <input type=text name= color2 size=16>
<p>
<input type=submit name=action value="Submit">
<input type=submit name=action value="Hint">
</form>
</font>
</body>
</html>

View File

@@ -0,0 +1,70 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<html>
<jsp:useBean id="cb" scope="session" class="colors.ColorGameBean" />
<jsp:setProperty name="cb" property="*" />
<%
cb.processRequest();
%>
<body bgcolor=<%= cb.getColor1() %>>
<font size=6 color=<%= cb.getColor2() %>>
<p>
<% if (cb.getHint()==true) { %>
<p> Hint #1: Vampires prey at night!
<p> <p> Hint #2: Nancy without the n.
<% } %>
<% if (cb.getSuccess()==true) { %>
<p> CONGRATULATIONS!!
<% if (cb.getHintTaken()==true) { %>
<p> ( although I know you cheated and peeked into the hints)
<% } %>
<% } %>
<p> Total attempts so far: <%= cb.getAttempts() %>
<p>
<p>
<form method=POST action=colrs.jsp>
Color #1: <input type=text name= color1 size=16>
<br>
Color #2: <input type=text name= color2 size=16>
<p>
<input type=submit name=action value="Submit">
<input type=submit name=action value="Hint">
</form>
</font>
</body>
</html>

View File

@@ -0,0 +1,31 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="date.jsp"><img src="../images/execute.gif" align="right" border="0"></a><a href="../index.html"><img src="../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="date.jsp.html">Source Code for Date Example<font color="#0000FF"></a>
</font> </h3>
</body>
</html>

View File

@@ -0,0 +1,41 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<html>
<%@ page session="false"%>
<body bgcolor="white">
<jsp:useBean id='clock' scope='page' class='dates.JspCalendar' type="dates.JspCalendar" />
<font size=4>
<ul>
<li> Day of month: is <jsp:getProperty name="clock" property="dayOfMonth"/>
<li> Year: is <jsp:getProperty name="clock" property="year"/>
<li> Month: is <jsp:getProperty name="clock" property="month"/>
<li> Time: is <jsp:getProperty name="clock" property="time"/>
<li> Date: is <jsp:getProperty name="clock" property="date"/>
<li> Day: is <jsp:getProperty name="clock" property="day"/>
<li> Day Of Year: is <jsp:getProperty name="clock" property="dayOfYear"/>
<li> Week Of Year: is <jsp:getProperty name="clock" property="weekOfYear"/>
<li> era: is <jsp:getProperty name="clock" property="era"/>
<li> DST Offset: is <jsp:getProperty name="clock" property="DSTOffset"/>
<li> Zone Offset: is <jsp:getProperty name="clock" property="zoneOffset"/>
</ul>
</font>
</body>
</html>

View File

@@ -0,0 +1,31 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="error.html"><img src="../images/execute.gif" align="right" border="0"></a><a href="../index.html"><img src="../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="err.jsp.html">Source Code for Error Example<font color="#0000FF"></a>
</font> </h3>
</body>
</html>

View File

@@ -0,0 +1,44 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<html>
<body bgcolor="lightblue">
<%@ page errorPage="errorpge.jsp" %>
<jsp:useBean id="foo" scope="request" class="error.Smart" />
<%
String name = null;
if (request.getParameter("name") == null) {
%>
<%@ include file="error.html" %>
<%
} else {
foo.setName(request.getParameter("name"));
if (foo.getName().equalsIgnoreCase("integra"))
name = "acura";
if (name.equalsIgnoreCase("acura")) {
%>
<H1> Yes!!! <a href="http://www.acura.com">Acura</a> is my favorite car.
<%
}
}
%>
</body>
</html>

View File

@@ -0,0 +1,37 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<body bgcolor="white">
<h1> This example uses <b>errorpage</b> directive </h1>
<br>
<h3> Select my favourite car.</h3>
<form method=get action=err.jsp>
<!-- <br> Make a guess: -->
<SELECT NAME="name" SIZE=5>
<OPTION VALUE="integra"> Acura Integra <BR>
<OPTION VALUE="bmw328i"> BMW 328I <BR>
<OPTION VALUE="z3"> BMW Z3 <BR>
<OPTION VALUE="infiniti"> InfinitiQ3 <BR>
<OPTION VALUE="audi"> Audi A8 <BR>
</SELECT>
<br> <INPUT TYPE=submit name=submit Value="Submit">
</form>
</body>
</html>

View File

@@ -0,0 +1,25 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<html>
<body bgcolor="red">
<%@ page isErrorPage="true" %>
<h1> The exception <%= exception.getMessage() %> tells me you
made a wrong choice.
</body>
</html>

View File

@@ -0,0 +1,33 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<html>
<%
double freeMem = Runtime.getRuntime().freeMemory();
double totlMem = Runtime.getRuntime().totalMemory();
double percent = freeMem/totlMem;
if (percent < 0.5) {
%>
<jsp:forward page="one.jsp"/>
<% } else { %>
<jsp:forward page="two.html"/>
<% } %>
</html>

View File

@@ -0,0 +1,30 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="forward.jsp"><img src="../images/execute.gif" align="right" border="0"></a><a href="../index.html"><img src="../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="forward.jsp.html">Source Code for Forward Example<font color="#0000FF"></a>
</font> </h3>
</body>
</html>

View File

@@ -0,0 +1,23 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<html>
<body bgcolor="white">
<font color="red">
VM Memory usage &lt; 50%.
</html>

View File

@@ -0,0 +1,23 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<body bgcolor="white">
<font color="red">
VM Memory usage &gt; 50%.
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -0,0 +1,17 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
To get the current time in ms

View File

@@ -0,0 +1,17 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%><%= System.currentTimeMillis() %>

View File

@@ -0,0 +1,30 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="include.jsp"><img src="../images/execute.gif" align="right" border="0"></a><a href="../index.html"><img src="../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="include.jsp.html">Source Code for Include Example<font color="#0000FF"></a>
</font> </h3>
</body>
</html>

View File

@@ -0,0 +1,30 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<html>
<body bgcolor="white">
<font color="red">
<%@ page buffer="5kb" autoFlush="false" %>
<p>In place evaluation of another JSP which gives you the current time: <%@ include file="foo.jsp" %>
<p> <jsp:include page="foo.html" flush="true"/> by including the output of another JSP: <jsp:include page="foo.jsp" flush="true"/>
:-)
</html>

View File

@@ -0,0 +1,369 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="Author" content="Anil K. Vijendran" />
<title>JSP Examples</title>
<style type="text/css">
img { border: 0; }
th { text-align: left; }
tr { vertical-align: top; }
</style>
</head>
<body>
<h1>JSP
Samples</h1>
<p>This is a collection of samples demonstrating the usage of different
parts of the Java Server Pages (JSP) specification. Both JSP 2.0 and
JSP 1.2 examples are presented below.
<p>These examples will only work when these pages are being served by a
servlet engine; of course, we recommend
<a href="https://tomcat.apache.org/">Tomcat</a>.
They will not work if you are viewing these pages via a
"file://..." URL.
<p>To navigate your way through the examples, the following icons will
help:</p>
<ul style="list-style-type: none; padding-left: 0;">
<li><img src="images/execute.gif" alt=""> Execute the example</li>
<li><img src="images/code.gif" alt=""> Look at the source code for the example</li>
<li><img src="images/return.gif" alt=""> Return to this screen</li>
</ul>
<p>Tip: For session scoped beans to work, the cookies must be enabled.
This can be done using browser options.</p>
<h2>JSP 2.0 Examples</h2>
<table style="width: 85%;">
<tr>
<th colspan="3">Expression Language</th>
</tr>
<tr>
<td>Basic Arithmetic</td>
<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>
<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>
</tr>
<tr>
<td>Basic Comparisons</td>
<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>
<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>
</tr>
<tr>
<td>Implicit Objects</td>
<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>
<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>
</tr>
<tr>
<td>Functions</td>
<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>
<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>
</tr>
<tr>
<td>Composite Expressions</td>
<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>
<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>
</tr>
<tr>
<th colspan="3"><br />SimpleTag Handlers and JSP Fragments</th>
</tr>
<tr>
<td>Hello World Tag</td>
<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>
<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>
</tr>
<tr>
<td>Repeat Tag</td>
<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>
<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>
</tr>
<tr>
<td>Book Example</td>
<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>
<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>
</tr>
<tr>
<th colspan="3"><br />Tag Files</th>
</tr>
<tr>
<td>Hello World Tag File</td>
<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>
<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>
</tr>
<tr>
<td>Panel Tag File</td>
<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>
<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>
</tr>
<tr>
<td>Display Products Example</td>
<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>
<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>
</tr>
<tr>
<th colspan="3"><br />New JSP XML Syntax (.jspx)</th>
</tr>
<tr>
<td>XHTML Basic Example</td>
<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>
<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>
</tr>
<tr>
<td>SVG (Scalable Vector Graphics)</td>
<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>
<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>
</tr>
<tr>
<th colspan="3"><br />Other JSP 2.0 Features</th>
</tr>
<tr>
<td>&lt;jsp:attribute&gt; and &lt;jsp:body&gt;</td>
<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>
<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>
</tr>
<tr>
<td>Shuffle Example</td>
<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>
<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>
</tr>
<tr>
<td>Attributes With Dynamic Names</td>
<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>
<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>
</tr>
<tr>
<td>JSP Configuration</td>
<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>
<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>
</tr>
</table>
<h2>JSP 1.2 Examples</h2>
<table style="width: 85%;">
<tr>
<td>Numberguess</td>
<td style="width: 30%;"><a href="num/numguess.jsp"><img src="images/execute.gif" alt=""></a><a href="num/numguess.jsp">Execute</a></td>
<td style="width: 30%;"><a href="num/numguess.html"><img src="images/code.gif" alt=""></a><a href="num/numguess.html">Source</a></td>
</tr>
<tr>
<td>Date</td>
<td style="width: 30%;"><a href="dates/date.jsp"><img src="images/execute.gif" alt=""></a><a href="dates/date.jsp">Execute</a></td>
<td style="width: 30%;"><a href="dates/date.html"><img src="images/code.gif" alt=""></a><a href="dates/date.html">Source</a></td>
</tr>
<tr>
<td>Snoop</td>
<td style="width: 30%;"><a href="snp/snoop.jsp"><img src="images/execute.gif" alt=""></a><a href="snp/snoop.jsp">Execute</a></td>
<td style="width: 30%;"><a href="snp/snoop.html"><img src="images/code.gif" alt=""></a><a href="snp/snoop.html">Source</a></td>
</tr>
<tr>
<td>ErrorPage</td>
<td style="width: 30%;"><a href="error/error.html"><img src="images/execute.gif" alt=""></a><a href="error/error.html">Execute</a></td>
<td style="width: 30%;"><a href="error/er.html"><img src="images/code.gif" alt=""></a><a href="error/er.html">Source</a></td>
</tr>
<tr>
<td>Carts</td>
<td style="width: 30%;"><a href="sessions/carts.html"><img src="images/execute.gif" alt=""></a><a href="sessions/carts.html">Execute</a></td>
<td style="width: 30%;"><a href="sessions/crt.html"><img src="images/code.gif" alt=""></a><a href="sessions/crt.html">Source</a></td>
</tr>
<tr>
<td>Checkbox</td>
<td style="width: 30%;"><a href="checkbox/check.html"><img src="images/execute.gif" alt=""></a><a href="checkbox/check.html">Execute</a></td>
<td style="width: 30%;"><a href="checkbox/cresult.html"><img src="images/code.gif" alt=""></a><a href="checkbox/cresult.html">Source</a></td>
</tr>
<tr>
<td>Color</td>
<td style="width: 30%;"><a href="colors/colors.html"><img src="images/execute.gif" alt=""></a><a href="colors/colors.html">Execute</a></td>
<td style="width: 30%;"><a href="colors/clr.html"><img src="images/code.gif" alt=""></a><a href="colors/clr.html">Source</a></td>
</tr>
<tr>
<td>Calendar</td>
<td style="width: 30%;"><a href="cal/login.html"><img src="images/execute.gif" alt=""></a><a href="cal/login.html">Execute</a></td>
<td style="width: 30%;"><a href="cal/calendar.html"><img src="images/code.gif" alt=""></a><a href="cal/calendar.html">Source</a></td>
</tr>
<tr>
<td>Include</td>
<td style="width: 30%;"><a href="include/include.jsp"><img src="images/execute.gif" alt=""></a><a href="include/include.jsp">Execute</a></td>
<td style="width: 30%;"><a href="include/inc.html"><img src="images/code.gif" alt=""></a><a href="include/inc.html">Source</a></td>
</tr>
<tr>
<td>Forward</td>
<td style="width: 30%;"><a href="forward/forward.jsp"><img src="images/execute.gif" alt=""></a><a href="forward/forward.jsp">Execute</a></td>
<td style="width: 30%;"><a href="forward/fwd.html"><img src="images/code.gif" alt=""></a><a href="forward/fwd.html">Source</a></td>
</tr>
<tr>
<td>Plugin</td>
<td style="width: 30%;"><a href="plugin/plugin.jsp"><img src="images/execute.gif" alt=""></a><a href="plugin/plugin.jsp">Execute</a></td>
<td style="width: 30%;"><a href="plugin/plugin.html"><img src="images/code.gif" alt=""></a><a href="plugin/plugin.html">Source</a></td>
</tr>
<tr>
<td>JSP-Servlet-JSP</td>
<td style="width: 30%;"><a href="jsptoserv/jsptoservlet.jsp"><img src="images/execute.gif" alt=""></a><a href="jsptoserv/jsptoservlet.jsp">Execute</a></td>
<td style="width: 30%;"><a href="jsptoserv/jts.html"><img src="images/code.gif" alt=""></a><a href="jsptoserv/jts.html">Source</a></td>
</tr>
<tr>
<td>Custom tag example</td>
<td style="width: 30%;"><a href="simpletag/foo.jsp"><img src="images/execute.gif" alt=""></a><a href="simpletag/foo.jsp">Execute</a></td>
<td style="width: 30%;"><a href="simpletag/foo.html"><img src="images/code.gif" alt=""></a><a href="simpletag/foo.html">Source</a></td>
</tr>
<tr>
<td>XML syntax example</td>
<td style="width: 30%;"><a href="xml/xml.jsp"><img src="images/execute.gif" alt=""></a><a href="xml/xml.jsp">Execute</a></td>
<td style="width: 30%;"><a href="xml/xml.html"><img src="images/code.gif" alt=""></a><a href="xml/xml.html">Source</a></td>
</tr>
</table>
<h2>Tag Plugins</h2>
<table style="width: 85%;">
<tr>
<td>If</td>
<td style="width: 30%;">
<a href="tagplugin/if.jsp"><img src="images/execute.gif" alt=""></a>
<a href="tagplugin/if.jsp">Execute</a>
</td>
<td style="width: 30%;">
<a href="tagplugin/if.html"><img src="images/code.gif" alt=""></a>
<a href="tagplugin/if.html">Source</a>
</td>
</tr>
<tr>
<td>ForEach</td>
<td style="width: 30%;">
<a href="tagplugin/foreach.jsp"><img src="images/execute.gif" alt=""></a>
<a href="tagplugin/foreach.jsp">Execute</a>
</td>
<td style="width: 30%;">
<a href="tagplugin/foreach.html"><img src="images/code.gif" alt=""></a>
<a href="tagplugin/foreach.html">Source</a>
</td>
</tr>
<tr>
<td>Choose</td>
<td style="width: 30%;">
<a href="tagplugin/choose.jsp"><img src="images/execute.gif" alt=""></a>
<a href="tagplugin/choose.jsp">Execute</a>
</td>
<td style="width: 30%;">
<a href="tagplugin/choose.html"><img src="images/code.gif" alt=""></a>
<a href="tagplugin/choose.html">Source</a>
</td>
</tr>
</table>
<h2>Other Examples</h2>
<table style="width: 85%;">
<tr>
<td>FORM Authentication</td>
<td style="width: 30%;">
<a href="security/protected/index.jsp"><img src="images/execute.gif" alt=""> Execute</a>
</td>
<td style="width: 30%;"></td>
</tr>
<tr>
<td colspan="3">Example that demonstrates protecting a resource and
using Form-Based authentication. To access the page the user must
have role of either "tomcat" or "role1". By default no user
is configured to have these roles.</td>
</tr>
</table>
</body>
</html>

View File

@@ -0,0 +1,30 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>View Source Code</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="basic-arithmetic.jsp"><img src="../../images/execute.gif" align="right" border="0"></a><a href="../../index.html"><img src="../../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="basic-arithmetic.jsp.html">Source Code for Basic Arithmetic Example<font color="#0000FF"></a>
</font> </h3>
</body>
</html>

View File

@@ -0,0 +1,88 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<html>
<head>
<title>JSP 2.0 Expression Language - Basic Arithmetic</title>
</head>
<body>
<h1>JSP 2.0 Expression Language - Basic Arithmetic</h1>
<hr>
This example illustrates basic Expression Language arithmetic.
Addition (+), subtraction (-), multiplication (*), division (/ or div),
and modulus (% or mod) are all supported. Error conditions, like
division by zero, are handled gracefully.
<br>
<blockquote>
<code>
<table border="1">
<thead>
<td><b>EL Expression</b></td>
<td><b>Result</b></td>
</thead>
<tr>
<td>\${1}</td>
<td>${1}</td>
</tr>
<tr>
<td>\${1 + 2}</td>
<td>${1 + 2}</td>
</tr>
<tr>
<td>\${1.2 + 2.3}</td>
<td>${1.2 + 2.3}</td>
</tr>
<tr>
<td>\${1.2E4 + 1.4}</td>
<td>${1.2E4 + 1.4}</td>
</tr>
<tr>
<td>\${-4 - 2}</td>
<td>${-4 - 2}</td>
</tr>
<tr>
<td>\${21 * 2}</td>
<td>${21 * 2}</td>
</tr>
<tr>
<td>\${3/4}</td>
<td>${3/4}</td>
</tr>
<tr>
<td>\${3 div 4}</td>
<td>${3 div 4}</td>
</tr>
<tr>
<td>\${3/0}</td>
<td>${3/0}</td>
</tr>
<tr>
<td>\${10%4}</td>
<td>${10%4}</td>
</tr>
<tr>
<td>\${10 mod 4}</td>
<td>${10 mod 4}</td>
</tr>
<tr>
<td>\${(1==2) ? 3 : 4}</td>
<td>${(1==2) ? 3 : 4}</td>
</tr>
</table>
</code>
</blockquote>
</body>
</html>

View File

@@ -0,0 +1,30 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>View Source Code</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="basic-comparisons.jsp"><img src="../../images/execute.gif" align="right" border="0"></a><a href="../../index.html"><img src="../../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="basic-comparisons.jsp.html">Source Code for Basic Comparisons Example<font color="#0000FF"></a>
</font> </h3>
</body>
</html>

View File

@@ -0,0 +1,116 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<html>
<head>
<title>JSP 2.0 Expression Language - Basic Comparisons</title>
</head>
<body>
<h1>JSP 2.0 Expression Language - Basic Comparisons</h1>
<hr>
This example illustrates basic Expression Language comparisons.
The following comparison operators are supported:
<ul>
<li>Less-than (&lt; or lt)</li>
<li>Greater-than (&gt; or gt)</li>
<li>Less-than-or-equal (&lt;= or le)</li>
<li>Greater-than-or-equal (&gt;= or ge)</li>
<li>Equal (== or eq)</li>
<li>Not Equal (!= or ne)</li>
</ul>
<blockquote>
<u><b>Numeric</b></u>
<code>
<table border="1">
<thead>
<td><b>EL Expression</b></td>
<td><b>Result</b></td>
</thead>
<tr>
<td>\${1 &lt; 2}</td>
<td>${1 < 2}</td>
</tr>
<tr>
<td>\${1 lt 2}</td>
<td>${1 lt 2}</td>
</tr>
<tr>
<td>\${1 &gt; (4/2)}</td>
<td>${1 > (4/2)}</td>
</tr>
<tr>
<td>\${1 gt (4/2)}</td>
<td>${1 gt (4/2)}</td>
</tr>
<tr>
<td>\${4.0 &gt;= 3}</td>
<td>${4.0 >= 3}</td>
</tr>
<tr>
<td>\${4.0 ge 3}</td>
<td>${4.0 ge 3}</td>
</tr>
<tr>
<td>\${4 &lt;= 3}</td>
<td>${4 <= 3}</td>
</tr>
<tr>
<td>\${4 le 3}</td>
<td>${4 le 3}</td>
</tr>
<tr>
<td>\${100.0 == 100}</td>
<td>${100.0 == 100}</td>
</tr>
<tr>
<td>\${100.0 eq 100}</td>
<td>${100.0 eq 100}</td>
</tr>
<tr>
<td>\${(10*10) != 100}</td>
<td>${(10*10) != 100}</td>
</tr>
<tr>
<td>\${(10*10) ne 100}</td>
<td>${(10*10) ne 100}</td>
</tr>
</table>
</code>
<br>
<u><b>Alphabetic</b></u>
<code>
<table border="1">
<thead>
<td><b>EL Expression</b></td>
<td><b>Result</b></td>
</thead>
<tr>
<td>\${'a' &lt; 'b'}</td>
<td>${'a' < 'b'}</td>
</tr>
<tr>
<td>\${'hip' &gt; 'hit'}</td>
<td>${'hip' > 'hit'}</td>
</tr>
<tr>
<td>\${'4' &gt; 3}</td>
<td>${'4' > 3}</td>
</tr>
</table>
</code>
</blockquote>
</body>
</html>

View File

@@ -0,0 +1,31 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>View Source Code</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="composite.jsp"><img src="../../images/execute.gif" align="right" border="0"></a><a href="../../index.html"><img src="../../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="composite.jsp.html">Source Code for composite.jsp</a></h3>
<h3><a href="ValuesTag.java.html">Source Code for ValuesTag.java</a></h3>
<h3><a href="ValuesBean.java.html">Source Code for ValuesBean.java</a></h3>
</body>
</html>

View File

@@ -0,0 +1,110 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<%@ taglib prefix="my" uri="http://tomcat.apache.org/example-taglib" %>
<html>
<head>
<title>JSP 2.0 Expression Language - Composite Expressions</title>
</head>
<body>
<h1>JSP 2.0 Expression Language - Composite Expressions</h1>
<hr>
This example illustrates EL composite expressions. Composite expressions
are formed by grouping together multiple EL expressions. Each of them is
evaluated from left to right, coerced to String, all those strings are
concatenated, and the result is coerced to the expected type.
<jsp:useBean id="values" class="jsp2.examples.ValuesBean" />
<blockquote>
<code>
<table border="1">
<thead>
<td><b>EL Expression</b></td>
<td><b>Type</b></td>
<td><b>Result</b></td>
</thead>
<tr>
<td>\${'hello'} wo\${'rld'}</td>
<td>String</td>
<td><jsp:setProperty name="values" property="stringValue" value="${'hello'} wo${'rld'}"/>${values.stringValue}</td>
</tr>
<tr>
<td>\${'hello'} wo\${'rld'}</td>
<td>String</td>
<td><my:values string="${'hello'} wo${'rld'}"/></td>
</tr>
<tr>
<td>\${1+2}.\${220}</td>
<td>Double</td>
<td><jsp:setProperty name="values" property="doubleValue" value="${1+2}.${220}"/>${values.doubleValue}</td>
</tr>
<tr>
<td>\${1+2}.\${220}</td>
<td>Double</td>
<td><my:values double="${1+2}.${220}"/></td>
</tr>
<tr>
<td>000\${1}\${7}</td>
<td>Long</td>
<td><jsp:setProperty name="values" property="longValue" value="000${1}${7}"/>${values.longValue}</td>
</tr>
<tr>
<td>000\${1}\${7}</td>
<td>Long</td>
<td><my:values long="000${1}${7}"/></td>
</tr>
<!--
Undefined values are to be coerced to String, to be "",
https://bz.apache.org/bugzilla/show_bug.cgi?id=47413
-->
<tr>
<td>\${undefinedFoo}hello world\${undefinedBar}</td>
<td>String</td>
<td><jsp:setProperty name="values" property="stringValue" value="${undefinedFoo}hello world${undefinedBar}"/>${values.stringValue}</td>
</tr>
<tr>
<td>\${undefinedFoo}hello world\${undefinedBar}</td>
<td>String</td>
<td><my:values string="${undefinedFoo}hello world${undefinedBar}"/></td>
</tr>
<tr>
<td>\${undefinedFoo}\${undefinedBar}</td>
<td>Double</td>
<td><jsp:setProperty name="values" property="doubleValue" value="${undefinedFoo}${undefinedBar}"/>${values.doubleValue}</td>
</tr>
<tr>
<td>\${undefinedFoo}\${undefinedBar}</td>
<td>Double</td>
<td><my:values double="${undefinedFoo}${undefinedBar}"/></td>
</tr>
<tr>
<td>\${undefinedFoo}\${undefinedBar}</td>
<td>Long</td>
<td><jsp:setProperty name="values" property="longValue" value="${undefinedFoo}${undefinedBar}"/>${values.longValue}</td>
</tr>
<tr>
<td>\${undefinedFoo}\${undefinedBar}</td>
<td>Long</td>
<td><my:values long="${undefinedFoo}${undefinedBar}"/></td>
</tr>
</table>
</code>
</blockquote>
</body>
</html>

View File

@@ -0,0 +1,32 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>View Source Code</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="functions.jsp?foo=JSP+2.0"><img src="../../images/execute.gif" align="right" border="0"></a><a href="../../index.html"><img src="../../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="functions.jsp.html">Source Code for functions.jsp<font color="#0000FF"></a>
</font> </h3>
<h3><a href="Functions.java.html">Source Code for Functions.java<font color="#0000FF"></a>
</font> </h3>
</body>
</html>

View File

@@ -0,0 +1,67 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<%@page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="my" uri="http://tomcat.apache.org/jsp2-example-taglib"%>
<html>
<head>
<title>JSP 2.0 Expression Language - Functions</title>
</head>
<body>
<h1>JSP 2.0 Expression Language - Functions</h1>
<hr>
An upgrade from the JSTL expression language, the JSP 2.0 EL also
allows for simple function invocation. Functions are defined
by tag libraries and are implemented by a Java programmer as
static methods.
<blockquote>
<u><b>Change Parameter</b></u>
<form action="functions.jsp" method="GET">
foo = <input type="text" name="foo" value="${fn:escapeXml(param["foo"])}">
<input type="submit">
</form>
<br>
<code>
<table border="1">
<thead>
<td><b>EL Expression</b></td>
<td><b>Result</b></td>
</thead>
<tr>
<td>\${param["foo"]}</td>
<td>${fn:escapeXml(param["foo"])}&nbsp;</td>
</tr>
<tr>
<td>\${my:reverse(param["foo"])}</td>
<td>${my:reverse(fn:escapeXml(param["foo"]))}&nbsp;</td>
</tr>
<tr>
<td>\${my:reverse(my:reverse(param["foo"]))}</td>
<td>${my:reverse(my:reverse(fn:escapeXml(param["foo"])))}&nbsp;</td>
</tr>
<tr>
<td>\${my:countVowels(param["foo"])}</td>
<td>${my:countVowels(fn:escapeXml(param["foo"]))}&nbsp;</td>
</tr>
</table>
</code>
</blockquote>
</body>
</html>

View File

@@ -0,0 +1,31 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>View Source Code</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="implicit-objects.jsp?foo=bar"><img src="../../images/execute.gif" align="right" border="0"></a><a href="../../index.html">
<img src="../../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="implicit-objects.jsp.html">Source Code for Implicit Objects Example<font color="#0000FF"></a>
</font> </h3>
</body>
</html>

View File

@@ -0,0 +1,90 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<%@page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<html>
<head>
<title>JSP 2.0 Expression Language - Implicit Objects</title>
</head>
<body>
<h1>JSP 2.0 Expression Language - Implicit Objects</h1>
<hr>
This example illustrates some of the implicit objects available
in the Expression Language. The following implicit objects are
available (not all illustrated here):
<ul>
<li>pageContext - the PageContext object</li>
<li>pageScope - a Map that maps page-scoped attribute names to
their values</li>
<li>requestScope - a Map that maps request-scoped attribute names
to their values</li>
<li>sessionScope - a Map that maps session-scoped attribute names
to their values</li>
<li>applicationScope - a Map that maps application-scoped attribute
names to their values</li>
<li>param - a Map that maps parameter names to a single String
parameter value</li>
<li>paramValues - a Map that maps parameter names to a String[] of
all values for that parameter</li>
<li>header - a Map that maps header names to a single String
header value</li>
<li>headerValues - a Map that maps header names to a String[] of
all values for that header</li>
<li>initParam - a Map that maps context initialization parameter
names to their String parameter value</li>
<li>cookie - a Map that maps cookie names to a single Cookie object.</li>
</ul>
<blockquote>
<u><b>Change Parameter</b></u>
<form action="implicit-objects.jsp" method="GET">
foo = <input type="text" name="foo" value="${fn:escapeXml(param["foo"])}">
<input type="submit">
</form>
<br>
<code>
<table border="1">
<thead>
<td><b>EL Expression</b></td>
<td><b>Result</b></td>
</thead>
<tr>
<td>\${param.foo}</td>
<td>${fn:escapeXml(param["foo"])}&nbsp;</td>
</tr>
<tr>
<td>\${param["foo"]}</td>
<td>${fn:escapeXml(param["foo"])}&nbsp;</td>
</tr>
<tr>
<td>\${header["host"]}</td>
<td>${fn:escapeXml(header["host"])}&nbsp;</td>
</tr>
<tr>
<td>\${header["accept"]}</td>
<td>${fn:escapeXml(header["accept"])}&nbsp;</td>
</tr>
<tr>
<td>\${header["user-agent"]}</td>
<td>${fn:escapeXml(header["user-agent"])}&nbsp;</td>
</tr>
</table>
</code>
</blockquote>
</body>
</html>

View File

@@ -0,0 +1,37 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>View Source Code</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="jspattribute.jsp"><img src="../../images/execute.gif" align="right" border="0"></a>
<a href="../../index.html"><img src="../../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="jspattribute.jsp.html">Source Code for jspattribute.jsp<font color="#0000FF"></a>
</font> </h3>
<h3><a href="HelloWorldSimpleTag.java.html">Source Code for HelloWorldSimpleTag.java<font color="#0000FF"></a>
</font> </h3>
<h3><a href="FooBean.java.html">Source Code for FooBean.java<font color="#0000FF"></a>
</font> </h3>
</body>
</html>

View File

@@ -0,0 +1,46 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<%@ taglib prefix="my" uri="http://tomcat.apache.org/jsp2-example-taglib"%>
<html>
<head>
<title>JSP 2.0 Examples - jsp:attribute and jsp:body</title>
</head>
<body>
<h1>JSP 2.0 Examples - jsp:attribute and jsp:body</h1>
<hr>
<p>The new &lt;jsp:attribute&gt; and &lt;jsp:body&gt;
standard actions can be used to specify the value of any standard
action or custom action attribute.</p>
<p>This example uses the &lt;jsp:attribute&gt;
standard action to use the output of a custom action invocation
(one that simply outputs "Hello, World!") to set the value of a
bean property. This would normally require an intermediary
step, such as using JSTL's &lt;c:set&gt; action.</p>
<br>
<jsp:useBean id="foo" class="jsp2.examples.FooBean">
Bean created! Setting foo.bar...<br>
<jsp:setProperty name="foo" property="bar">
<jsp:attribute name="value">
<my:helloWorld/>
</jsp:attribute>
</jsp:setProperty>
</jsp:useBean>
<br>
Result: ${foo.bar}
</body>
</html>

View File

@@ -0,0 +1,37 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>View Source Code</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="shuffle.jsp"><img src="../../images/execute.gif" align="right" border="0"></a>
<a href="../../index.html"><img src="../../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="shuffle.jsp.html">Source Code for shuffle.jsp<font color="#0000FF"></a>
</font> </h3>
<h3><a href="ShuffleSimpleTag.java.html">Source Code for ShuffleSimpleTag.java<font color="#0000FF"></a>
</font> </h3>
<h3><a href="TileSimpleTag.java.html">Source Code for TileSimpleTag.java<font color="#0000FF"></a>
</font> </h3>
</body>
</html>

View File

@@ -0,0 +1,90 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<%@ taglib prefix="my" uri="http://tomcat.apache.org/jsp2-example-taglib"%>
<html>
<head>
<title>JSP 2.0 Examples - Shuffle Example</title>
</head>
<body>
<h1>JSP 2.0 Examples - Shuffle Example</h1>
<hr>
<p>Try reloading the page a few times. Both the rows and the columns
are shuffled and appear different each time.</p>
<p>Here's how the code works. The SimpleTag handler called
&lt;my:shuffle&gt; accepts three attributes. Each attribute is a
JSP Fragment, meaning it is a fragment of JSP code that can be
dynamically executed by the shuffle tag handler on demand. The
shuffle tag handler executes the three fragments in a random order.
To shuffle both the rows and the columns, the shuffle tag is used
with itself as a parameter.</p>
<hr>
<blockquote>
<font color="#ffffff">
<table>
<my:shuffle>
<jsp:attribute name="fragment1">
<tr>
<my:shuffle>
<jsp:attribute name="fragment1">
<my:tile color="#ff0000" label="A"/>
</jsp:attribute>
<jsp:attribute name="fragment2">
<my:tile color="#00ff00" label="B"/>
</jsp:attribute>
<jsp:attribute name="fragment3">
<my:tile color="#0000ff" label="C"/>
</jsp:attribute>
</my:shuffle>
</tr>
</jsp:attribute>
<jsp:attribute name="fragment2">
<tr>
<my:shuffle>
<jsp:attribute name="fragment1">
<my:tile color="#ff0000" label="1"/>
</jsp:attribute>
<jsp:attribute name="fragment2">
<my:tile color="#00ff00" label="2"/>
</jsp:attribute>
<jsp:attribute name="fragment3">
<my:tile color="#0000ff" label="3"/>
</jsp:attribute>
</my:shuffle>
</tr>
</jsp:attribute>
<jsp:attribute name="fragment3">
<tr>
<my:shuffle>
<jsp:attribute name="fragment1">
<my:tile color="#ff0000" label="!"/>
</jsp:attribute>
<jsp:attribute name="fragment2">
<my:tile color="#00ff00" label="@"/>
</jsp:attribute>
<jsp:attribute name="fragment3">
<my:tile color="#0000ff" label="#"/>
</jsp:attribute>
</my:shuffle>
</tr>
</jsp:attribute>
</my:shuffle>
</table>
</font>
</blockquote>
</body>
</html>

View File

@@ -0,0 +1,31 @@
<!DOCTYPE html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html lang="en">
<head>
<meta charset="UTF-8">
<title>View Source Code</title>
</head>
<body>
<p><a href="basic.jspx"><img src="../../images/execute.gif" alt="Execute" style="border: 0;"></a><a
href="../../index.html"><img src="../../images/return.gif" alt="Return" style="border: 0;"></a></p>
<h3><a href="basic.jspx.html">Source Code for XHTML Basic Example</a></h3>
</body>
</html>

View File

@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
xmlns="http://www.w3.org/1999/xhtml">
<jsp:output doctype-root-element="html"
doctype-public="-//W3C//DTD XHTML Basic 1.0//EN"
doctype-system="http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd"/>
<jsp:directive.page contentType="application/xhtml+xml" />
<head>
<title>JSPX - XHTML Basic Example</title>
</head>
<body>
<h1>JSPX - XHTML Basic Example</h1>
This example illustrates how to use JSPX to produce an XHTML basic
document suitable for use with mobile phones, televisions,
PDAs, vending machines, pagers, car navigation systems,
mobile game machines, digital book readers, smart watches, etc.
<p/>
JSPX lets you create dynamic documents in a pure XML syntax compatible
with existing XML tools. The XML syntax in JSP 1.2 was awkward and
required &amp;lt;jsp:root&amp;gt; to be the root element of the document.
This is no longer the case in JSP 2.0.
<p/>
This particular example uses
namespace declarations to make the output of this page a valid XHTML
document.
<p/>
Just to prove this is live, here's some dynamic content:
<jsp:useBean id="now" class="java.util.Date" />
<fmt:formatDate value="${now}" pattern="MMMM d, yyyy, H:mm:ss"/>
</body>
</html>

View File

@@ -0,0 +1,46 @@
<!DOCTYPE html><!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
<head>
<meta charset="UTF-8">
<title>JSP 2.0 SVG Example</title>
</head>
<body>
<h1>JSP 2.0 SVG Example</h1>
This example uses JSP 2.0's new, simplified JSPX syntax to render a
Scalable Vector Graphics (SVG) document. When you view the source,
notice the lack of a &lt;jsp:root&gt; element! The text to be rendered
can be modified by changing the value of the name parameter.
<p>
SVG has many potential uses, such as searchable images, or images
customized with the name of your site's visitor (e.g. a "Susan's Store"
tab image). JSPX is a natural fit for generating dynamic XML content
such as SVG.
<p>
To execute this example you will need a browser with basic SVG support. Any
remotely recent browser should have this.
<ol>
<li>Use this URL:
<a href="textRotate.jspx?name=JSPX">textRotate.jspx?name=JSPX</a></li>
<li>Customize by changing the name=JSPX parameter</li>
</ol>
<p style="margin-top: 2em;">
The following is a screenshot of the resulting image, for those using a
browser without SVG support:<br>
<img src="textRotate.jpg" alt="[Screenshot image]" style="border: 1px solid #000;">
</body>
</html>

View File

@@ -0,0 +1,32 @@
<!DOCTYPE html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html lang="en">
<head>
<meta charset="UTF-8">
<title>View Source Code</title>
</head>
<body>
<p><a href="textRotate.jspx"><img src="../../images/execute.gif" alt="Execute" style="border: 0;"></a> <a
href="../../index.html"><img src="../../images/return.gif" alt="Return" style="border: 0;"></a></p>
<h3><a href="textRotate.jspx.html">Source Code for SVG (Scalable Vector Graphics)
Example</a></h3>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--
- This example is based off the textRotate.svg example that comes
- with Apache Batik. The original example was written by Bill Haneman.
- This version by Mark Roth.
-->
<svg xmlns="http://www.w3.org/2000/svg"
width="450" height="500" viewBox="0 0 450 500"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:jsp="http://java.sun.com/JSP/Page">
<jsp:directive.page contentType="image/svg+xml" />
<title>JSP 2.0 JSPX</title>
<!-- select name parameter, or default to JSPX -->
<c:set var="name" value='${empty fn:escapeXml(param["name"]) ? "JSPX" : fn:escapeXml(param["name"])}'/>
<g id="testContent">
<text class="title" x="50%" y="10%" font-size="15" text-anchor="middle" >
JSP 2.0 XML Syntax (.jspx) Demo</text>
<text class="title" x="50%" y="15%" font-size="15" text-anchor="middle" >
Try changing the name parameter!</text>
<g opacity="1.0" transform="translate(225, 250)" id="rotatedText">
<c:forEach var="i" begin="1" end="24">
<jsp:text>
<![CDATA[<g opacity="0.95" transform="scale(1.05) rotate(15)">]]>
</jsp:text>
<text x="0" y="0" transform="scale(1.6, 1.6)" fill="DarkSlateBlue"
text-anchor="middle" font-size="40" font-family="Serif"
id="words">${name}</text>
</c:forEach>
<c:forEach var="i" begin="1" end="24">
<jsp:text><![CDATA[</g>]]></jsp:text>
</c:forEach>
<text style="font-size:75;font-family:Serif;fill:white"
text-anchor="middle">${name}</text>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -0,0 +1,21 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<hr>
<center>
This banner included with &lt;include-coda&gt;
</center>
<hr>

View File

@@ -0,0 +1,35 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>View Source Code</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="config.jsp"><img src="../../images/execute.gif" align="right" border="0"></a>
<a href="../../index.html"><img src="../../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="config.jsp.html">Source Code for config.jsp<font color="#0000FF"></a>
</font> </h3>
<h3><a href="prelude.jspf.html">Source Code for prelude.jspf<font color="#0000FF"></a>
</font> </h3>
<h3><a href="coda.jspf.html">Source Code for coda.jspf<font color="#0000FF"></a>
</font> </h3>
</body>
</html>

View File

@@ -0,0 +1,32 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<%@ taglib prefix="my" uri="http://tomcat.apache.org/jsp2-example-taglib"%>
<h1>JSP 2.0 Examples - JSP Configuration</h1>
<hr>
<p>Using a &lt;jsp-property-group&gt; element in the web.xml
deployment descriptor, this JSP page has been configured in the
following ways:</p>
<ul>
<li>Uses &lt;include-prelude&gt; to include the top banner.</li>
<li>Uses &lt;include-coda&gt; to include the bottom banner.</li>
<li>Uses &lt;scripting-invalid&gt; true to disable
&lt;% scripting %&gt; elements</li>
<li>Uses &lt;el-ignored&gt; true to disable ${EL} elements</li>
<li>Uses &lt;page-encoding&gt; ISO-8859-1 to set the page encoding (though this is the default anyway)</li>
</ul>
There are various other configuration options that can be used.

View File

@@ -0,0 +1,33 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>View Source Code</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="dynamicattrs.jsp"><img src="../../images/execute.gif" align="right" border="0"></a>
<a href="../../index.html"><img src="../../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="dynamicattrs.jsp.html">Source Code for dynamicattrs.jsp<font color="#0000FF"></a>
</font> </h3>
<h3><a href="EchoAttributesTag.java.html">Source Code for EchoAttributesTag.java<font color="#0000FF"></a>
</font> </h3>
</body>
</html>

View File

@@ -0,0 +1,44 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<%@ taglib prefix="my" uri="http://tomcat.apache.org/jsp2-example-taglib"%>
<html>
<head>
<title>JSP 2.0 Examples - Dynamic Attributes</title>
</head>
<body>
<h1>JSP 2.0 Examples - Dynamic Attributes</h1>
<hr>
<p>This JSP page invokes a custom tag that accepts a dynamic set
of attributes. The tag echoes the name and value of all attributes
passed to it.</p>
<hr>
<h2>Invocation 1 (six attributes)</h2>
<ul>
<my:echoAttributes x="1" y="2" z="3" r="red" g="green" b="blue"/>
</ul>
<h2>Invocation 2 (zero attributes)</h2>
<ul>
<my:echoAttributes/>
</ul>
<h2>Invocation 3 (three attributes)</h2>
<ul>
<my:echoAttributes dogName="Scruffy"
catName="Fluffy"
blowfishName="Puffy"/>
</ul>
</body>
</html>

View File

@@ -0,0 +1,21 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<hr>
<center>
This banner included with &lt;include-prelude&gt;
</center>
<hr>

View File

@@ -0,0 +1,37 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>View Source Code</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="book.jsp"><img src="../../images/execute.gif" align="right" border="0"></a>
<a href="../../index.html"><img src="../../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="book.jsp.html">Source Code for the Book Example JSP<font color="#0000FF"></a>
</font> </h3>
<h3><a href="FindBookSimpleTag.java.html">Source Code for the FindBook SimpleTag Handler<font color="#0000FF"></a>
</font> </h3>
<h3><a href="BookBean.java.html">Source Code for BookBean<font color="#0000FF"></a>
</font> </h3>
<h3><a href="Functions.java.html">Source Code for the EL Functions<font color="#0000FF"></a>
</font> </h3>
</body>
</html>

View File

@@ -0,0 +1,55 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<%@ taglib prefix="my" uri="/WEB-INF/jsp2/jsp2-example-taglib.tld" %>
<html>
<head>
<title>JSP 2.0 Examples - Book SimpleTag Handler</title>
</head>
<body>
<h1>JSP 2.0 Examples - Book SimpleTag Handler</h1>
<hr>
<p>Illustrates a semi-realistic use of SimpleTag and the Expression
Language. First, a &lt;my:findBook&gt; tag is invoked to populate
the page context with a BookBean. Then, the books fields are printed
in all caps.</p>
<br>
<b><u>Result:</u></b><br>
<my:findBook var="book"/>
<table border="1">
<thead>
<td><b>Field</b></td>
<td><b>Value</b></td>
<td><b>Capitalized</b></td>
</thead>
<tr>
<td>Title</td>
<td>${book.title}</td>
<td>${my:caps(book.title)}</td>
</tr>
<tr>
<td>Author</td>
<td>${book.author}</td>
<td>${my:caps(book.author)}</td>
</tr>
<tr>
<td>ISBN</td>
<td>${book.isbn}</td>
<td>${my:caps(book.isbn)}</td>
</tr>
</table>
</body>
</html>

View File

@@ -0,0 +1,33 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>View Source Code</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="hello.jsp"><img src="../../images/execute.gif" align="right" border="0"></a>
<a href="../../index.html"><img src="../../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="hello.jsp.html">Source Code for the Hello World Tag Example JSP<font color="#0000FF"></a>
</font> </h3>
<h3><a href="HelloWorldSimpleTag.java.html">Source Code for the Hello World SimpleTag Handler<font color="#0000FF"></a>
</font> </h3>
</body>
</html>

View File

@@ -0,0 +1,31 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<%@ taglib prefix="mytag" uri="/WEB-INF/jsp2/jsp2-example-taglib.tld" %>
<html>
<head>
<title>JSP 2.0 Examples - Hello World SimpleTag Handler</title>
</head>
<body>
<h1>JSP 2.0 Examples - Hello World SimpleTag Handler</h1>
<hr>
<p>This tag handler simply echos "Hello, World!" It's an example of
a very basic SimpleTag handler with no body.</p>
<br>
<b><u>Result:</u></b>
<mytag:helloWorld/>
</body>
</html>

View File

@@ -0,0 +1,33 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>View Source Code</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="repeat.jsp"><img src="../../images/execute.gif" align="right" border="0"></a>
<a href="../../index.html"><img src="../../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="repeat.jsp.html">Source Code for the Repeat Tag Example JSP<font color="#0000FF"></a>
</font> </h3>
<h3><a href="RepeatSimpleTag.java.html">Source Code for the Repeat SimpleTag Handler<font color="#0000FF"></a>
</font> </h3>
</body>
</html>

View File

@@ -0,0 +1,39 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<%@ taglib prefix="mytag" uri="/WEB-INF/jsp2/jsp2-example-taglib.tld" %>
<html>
<head>
<title>JSP 2.0 Examples - Repeat SimpleTag Handler</title>
</head>
<body>
<h1>JSP 2.0 Examples - Repeat SimpleTag Handler</h1>
<hr>
<p>This tag handler accepts a "num" parameter and repeats the body of the
tag "num" times. It's a simple example, but the implementation of
such a tag in JSP 2.0 is substantially simpler than the equivalent
JSP 1.2-style classic tag handler.</p>
<p>The body of the tag is encapsulated in a "JSP Fragment" and passed
to the tag handler, which then executes it five times, inside a
for loop. The tag handler passes in the current invocation in a
scoped variable called count, which can be accessed using the EL.</p>
<br>
<b><u>Result:</u></b><br>
<mytag:repeat num="5">
Invocation ${count} of 5<br>
</mytag:repeat>
</body>
</html>

View File

@@ -0,0 +1,33 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>View Source Code</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="hello.jsp"><img src="../../images/execute.gif" align="right" border="0"></a>
<a href="../../index.html"><img src="../../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="hello.jsp.html">Source Code for hello.jsp<font color="#0000FF"></a>
</font> </h3>
<h3><a href="helloWorld.tag.html">Source Code for helloWorld.tag<font color="#0000FF"></a>
</font> </h3>
</body>
</html>

View File

@@ -0,0 +1,35 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<html>
<head>
<title>JSP 2.0 Examples - Hello World Using a Tag File</title>
</head>
<body>
<h1>JSP 2.0 Examples - Hello World Using a Tag File</h1>
<hr>
<p>This JSP page invokes a custom tag that simply echos "Hello, World!"
The custom tag is generated from a tag file in the /WEB-INF/tags
directory.</p>
<p>Notice that we did not need to write a TLD for this tag. We just
created /WEB-INF/tags/helloWorld.tag, imported it using the taglib
directive, and used it!</p>
<br>
<b><u>Result:</u></b>
<tags:helloWorld/>
</body>
</html>

View File

@@ -0,0 +1,33 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>View Source Code</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="panel.jsp"><img src="../../images/execute.gif" align="right" border="0"></a>
<a href="../../index.html"><img src="../../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="panel.jsp.html">Source Code for panel.jsp<font color="#0000FF"></a>
</font> </h3>
<h3><a href="panel.tag.html">Source Code for panel.tag<font color="#0000FF"></a>
</font> </h3>
</body>
</html>

View File

@@ -0,0 +1,58 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<html>
<head>
<title>JSP 2.0 Examples - Panels using Tag Files</title>
</head>
<body>
<h1>JSP 2.0 Examples - Panels using Tag Files</h1>
<hr>
<p>This JSP page invokes a custom tag that draws a
panel around the contents of the tag body. Normally, such a tag
implementation would require a Java class with many println() statements,
outputting HTML. Instead, we can use a .tag file as a template,
and we don't need to write a single line of Java or even a TLD!</p>
<hr>
<table border="0">
<tr valign="top">
<td>
<tags:panel color="#ff8080" bgcolor="#ffc0c0" title="Panel 1">
First panel.<br/>
</tags:panel>
</td>
<td>
<tags:panel color="#80ff80" bgcolor="#c0ffc0" title="Panel 2">
Second panel.<br/>
Second panel.<br/>
Second panel.<br/>
Second panel.<br/>
</tags:panel>
</td>
<td>
<tags:panel color="#8080ff" bgcolor="#c0c0ff" title="Panel 3">
Third panel.<br/>
<tags:panel color="#ff80ff" bgcolor="#ffc0ff" title="Inner">
A panel in a panel.
</tags:panel>
Third panel.<br/>
</tags:panel>
</td>
</tr>
</table>
</body>
</html>

View File

@@ -0,0 +1,33 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>View Source Code</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="products.jsp"><img src="../../images/execute.gif" align="right" border="0"></a>
<a href="../../index.html"><img src="../../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="products.jsp.html">Source Code for products.jsp<font color="#0000FF"></a>
</font> </h3>
<h3><a href="displayProducts.tag.html">Source Code for displayProducts.tag<font color="#0000FF"></a>
</font> </h3>
</body>
</html>

View File

@@ -0,0 +1,54 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<html>
<head>
<title>JSP 2.0 Examples - Display Products Tag File</title>
</head>
<body>
<h1>JSP 2.0 Examples - Display Products Tag File</h1>
<hr>
<p>This JSP page invokes a tag file that displays a listing of
products. The custom tag accepts two fragments that enable
customization of appearance. One for when the product is on sale
and one for normal price.</p>
<p>The tag is invoked twice, using different styles</p>
<hr>
<h2>Products</h2>
<tags:displayProducts>
<jsp:attribute name="normalPrice">
Item: ${name}<br/>
Price: ${price}
</jsp:attribute>
<jsp:attribute name="onSale">
Item: ${name}<br/>
<font color="red"><strike>Was: ${origPrice}</strike></font><br/>
<b>Now: ${salePrice}</b>
</jsp:attribute>
</tags:displayProducts>
<hr>
<h2>Products (Same tag, alternate style)</h2>
<tags:displayProducts>
<jsp:attribute name="normalPrice">
<b>${name}</b> @ ${price} ea.
</jsp:attribute>
<jsp:attribute name="onSale">
<b>${name}</b> @ ${salePrice} ea. (was: ${origPrice})
</jsp:attribute>
</tags:displayProducts>
</body>
</html>

View File

@@ -0,0 +1,26 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<html>
<body bgcolor="white">
<h1>
I have been invoked by
<% out.print (request.getAttribute("servletName").toString()); %>
Servlet.
</h1>
</html>

View File

@@ -0,0 +1,23 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<html>
<body bgcolor="white">
<!-- Forward to a servlet -->
<jsp:forward page="/servletToJsp" />
</html>

View File

@@ -0,0 +1,36 @@
<!DOCTYPE html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
<head>
<meta charset="UTF-8" />
<title>Untitled Document</title>
<style type="text/css">
img { border: 0; }
</style>
</head>
<body>
<p><a href="jsptoservlet.jsp"><img src="../images/execute.gif" alt=""> Execute</a><br />
<a href="../index.html"><img src="../images/return.gif" alt=""> Return</a></p>
<p style="font-size: 1.4em;"><a href="jsptoservlet.jsp.html">Source Code for JSP calling servlet</a></p>
<p style="font-size: 1.4em;"><a href="ServletToJsp.java.html">Source Code for Servlet calling JSP</a></p>
</body>
</html>

View File

@@ -0,0 +1,34 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Number Guess Game
Written by Jason Hunter, CTO, K&A Software
http://www.servlets.com
-->
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="numguess.jsp"><img src="../images/execute.gif" align="right" border="0"></a><a href="../index.html"><img src="../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="numguess.jsp.html">Source Code for Numguess Example<font color="#0000FF"></a>
</font> </h3>
</body>
</html>

View File

@@ -0,0 +1,69 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Number Guess Game
Written by Jason Hunter, CTO, K&A Software
http://www.servlets.com
--%>
<%@ page import = "num.NumberGuessBean" %>
<jsp:useBean id="numguess" class="num.NumberGuessBean" scope="session"/>
<jsp:setProperty name="numguess" property="*"/>
<html>
<head><title>Number Guess</title></head>
<body bgcolor="white">
<font size=4>
<% if (numguess.getSuccess()) { %>
Congratulations! You got it.
And after just <%= numguess.getNumGuesses() %> tries.<p>
<% numguess.reset(); %>
Care to <a href="numguess.jsp">try again</a>?
<% } else if (numguess.getNumGuesses() == 0) { %>
Welcome to the Number Guess game.<p>
I'm thinking of a number between 1 and 100.<p>
<form method=get>
What's your guess? <input type=text name=guess>
<input type=submit value="Submit">
</form>
<% } else { %>
Good guess, but nope. Try <b><%= numguess.getHint() %></b>.
You have made <%= numguess.getNumGuesses() %> guesses.<p>
I'm thinking of a number between 1 and 100.<p>
<form method=get>
What's your guess? <input type=text name=guess>
<input type=submit value="Submit">
</form>
<% } %>
</font>
</body>
</html>

View File

@@ -0,0 +1,230 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.applet.Applet;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
/**
* Time!
*
* @author Rachel Gollub
*/
public class Clock2 extends Applet implements Runnable {
private static final long serialVersionUID = 1L;
Thread timer; // The thread that displays clock
int lastxs, lastys, lastxm,
lastym, lastxh, lastyh; // Dimensions used to draw hands
SimpleDateFormat formatter; // Formats the date displayed
String lastdate; // String to hold date displayed
Font clockFaceFont; // Font for number display on clock
Date currentDate; // Used to get date to display
Color handColor; // Color of main hands and dial
Color numberColor; // Color of second hand and numbers
@Override
public void init() {
lastxs = lastys = lastxm = lastym = lastxh = lastyh = 0;
formatter = new SimpleDateFormat ("EEE MMM dd hh:mm:ss yyyy", Locale.getDefault());
currentDate = new Date();
lastdate = formatter.format(currentDate);
clockFaceFont = new Font("Serif", Font.PLAIN, 14);
handColor = Color.blue;
numberColor = Color.darkGray;
try {
setBackground(new Color(Integer.parseInt(getParameter("bgcolor"),16)));
} catch (Exception e) {
// Ignored
}
try {
handColor = new Color(Integer.parseInt(getParameter("fgcolor1"),16));
} catch (Exception e) {
// Ignored
}
try {
numberColor = new Color(Integer.parseInt(getParameter("fgcolor2"),16));
} catch (Exception e) {
// Ignored
}
resize(300,300); // Set clock window size
}
// Plotpoints allows calculation to only cover 45 degrees of the circle,
// and then mirror
public void plotpoints(int x0, int y0, int x, int y, Graphics g) {
g.drawLine(x0+x,y0+y,x0+x,y0+y);
g.drawLine(x0+y,y0+x,x0+y,y0+x);
g.drawLine(x0+y,y0-x,x0+y,y0-x);
g.drawLine(x0+x,y0-y,x0+x,y0-y);
g.drawLine(x0-x,y0-y,x0-x,y0-y);
g.drawLine(x0-y,y0-x,x0-y,y0-x);
g.drawLine(x0-y,y0+x,x0-y,y0+x);
g.drawLine(x0-x,y0+y,x0-x,y0+y);
}
// Circle is just Bresenham's algorithm for a scan converted circle
public void circle(int x0, int y0, int r, Graphics g) {
int x,y;
float d;
x=0;
y=r;
d=5/4-r;
plotpoints(x0,y0,x,y,g);
while (y>x){
if (d<0) {
d=d+2*x+3;
x++;
}
else {
d=d+2*(x-y)+5;
x++;
y--;
}
plotpoints(x0,y0,x,y,g);
}
}
// Paint is the main part of the program
@Override
public void paint(Graphics g) {
int xh, yh, xm, ym, xs, ys, s = 0, m = 10, h = 10, xcenter, ycenter;
String today;
currentDate = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("s",Locale.getDefault());
try {
s = Integer.parseInt(formatter.format(currentDate));
} catch (NumberFormatException n) {
s = 0;
}
formatter.applyPattern("m");
try {
m = Integer.parseInt(formatter.format(currentDate));
} catch (NumberFormatException n) {
m = 10;
}
formatter.applyPattern("h");
try {
h = Integer.parseInt(formatter.format(currentDate));
} catch (NumberFormatException n) {
h = 10;
}
formatter.applyPattern("EEE MMM dd HH:mm:ss yyyy");
today = formatter.format(currentDate);
xcenter=80;
ycenter=55;
// a= s* pi/2 - pi/2 (to switch 0,0 from 3:00 to 12:00)
// x = r(cos a) + xcenter, y = r(sin a) + ycenter
xs = (int)(Math.cos(s * 3.14f/30 - 3.14f/2) * 45 + xcenter);
ys = (int)(Math.sin(s * 3.14f/30 - 3.14f/2) * 45 + ycenter);
xm = (int)(Math.cos(m * 3.14f/30 - 3.14f/2) * 40 + xcenter);
ym = (int)(Math.sin(m * 3.14f/30 - 3.14f/2) * 40 + ycenter);
xh = (int)(Math.cos((h*30 + m/2) * 3.14f/180 - 3.14f/2) * 30 + xcenter);
yh = (int)(Math.sin((h*30 + m/2) * 3.14f/180 - 3.14f/2) * 30 + ycenter);
// Draw the circle and numbers
g.setFont(clockFaceFont);
g.setColor(handColor);
circle(xcenter,ycenter,50,g);
g.setColor(numberColor);
g.drawString("9",xcenter-45,ycenter+3);
g.drawString("3",xcenter+40,ycenter+3);
g.drawString("12",xcenter-5,ycenter-37);
g.drawString("6",xcenter-3,ycenter+45);
// Erase if necessary, and redraw
g.setColor(getBackground());
if (xs != lastxs || ys != lastys) {
g.drawLine(xcenter, ycenter, lastxs, lastys);
g.drawString(lastdate, 5, 125);
}
if (xm != lastxm || ym != lastym) {
g.drawLine(xcenter, ycenter-1, lastxm, lastym);
g.drawLine(xcenter-1, ycenter, lastxm, lastym); }
if (xh != lastxh || yh != lastyh) {
g.drawLine(xcenter, ycenter-1, lastxh, lastyh);
g.drawLine(xcenter-1, ycenter, lastxh, lastyh); }
g.setColor(numberColor);
g.drawString("", 5, 125);
g.drawString(today, 5, 125);
g.drawLine(xcenter, ycenter, xs, ys);
g.setColor(handColor);
g.drawLine(xcenter, ycenter-1, xm, ym);
g.drawLine(xcenter-1, ycenter, xm, ym);
g.drawLine(xcenter, ycenter-1, xh, yh);
g.drawLine(xcenter-1, ycenter, xh, yh);
lastxs=xs; lastys=ys;
lastxm=xm; lastym=ym;
lastxh=xh; lastyh=yh;
lastdate = today;
currentDate=null;
}
@Override
public void start() {
timer = new Thread(this);
timer.start();
}
@Override
public void stop() {
timer = null;
}
@Override
public void run() {
Thread me = Thread.currentThread();
while (timer == me) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
repaint();
}
}
@Override
public void update(Graphics g) {
paint(g);
}
@Override
public String getAppletInfo() {
return "Title: A Clock \nAuthor: Rachel Gollub, 1995 \nAn analog clock.";
}
@Override
public String[][] getParameterInfo() {
String[][] info = {
{"bgcolor", "hexadecimal RGB number", "The background color. Default is the color of your browser."},
{"fgcolor1", "hexadecimal RGB number", "The color of the hands and dial. Default is blue."},
{"fgcolor2", "hexadecimal RGB number", "The color of the seconds hand and numbers. Default is dark gray."}
};
return info;
}
}

View File

@@ -0,0 +1,30 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="plugin.jsp"><img src="../images/execute.gif" align="right" border="0"></a><a href="../index.html"><img src="../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="plugin.jsp.html">Source Code for Plugin Example<font color="#0000FF"></a>
</font> </h3>
</body>
</html>

View File

@@ -0,0 +1,34 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<html>
<title> Plugin example </title>
<body bgcolor="white">
<h3> Current time is : </h3>
<jsp:plugin type="applet" code="Clock2.class" codebase="applet" jreversion="1.2" width="160" height="150" >
<jsp:fallback>
Plugin tag OBJECT or EMBED not supported by browser.
</jsp:fallback>
</jsp:plugin>
<p>
<h4>
<font color=red>
The above applet is loaded using the Java Plugin from a jsp page using the
plugin tag.
</font>
</h4>
</body>
</html>

View File

@@ -0,0 +1,25 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<html>
<head>
<title>Error Page For Examples</title>
</head>
<body bgcolor="white">
Invalid user name and/or password, please try
<a href='<%= response.encodeURL(application.getContextPath() + "/jsp/security/protected/index.jsp") %>'>again</a>.
</body>
</html>

View File

@@ -0,0 +1,112 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<%@ page import="java.util.Enumeration" %>
<%
if (request.getParameter("logoff") != null) {
session.invalidate();
response.sendRedirect("index.jsp");
return;
}
%>
<html>
<head>
<title>Protected Page for Examples</title>
</head>
<body bgcolor="white">
You are logged in as remote user
<b><%= util.HTMLFilter.filter(request.getRemoteUser()) %></b>
in session <b><%= session.getId() %></b><br><br>
<%
if (request.getUserPrincipal() != null) {
%>
Your user principal name is
<b><%= util.HTMLFilter.filter(request.getUserPrincipal().getName()) %></b>
<br><br>
<%
} else {
%>
No user principal could be identified.<br><br>
<%
}
%>
<%
String role = request.getParameter("role");
if (role == null)
role = "";
if (role.length() > 0) {
if (request.isUserInRole(role)) {
%>
You have been granted role
<b><%= util.HTMLFilter.filter(role) %></b><br><br>
<%
} else {
%>
You have <i>not</i> been granted role
<b><%= util.HTMLFilter.filter(role) %></b><br><br>
<%
}
}
%>
To check whether your user name has been granted a particular role,
enter it here:
<form method="GET" action='<%= response.encodeURL("index.jsp") %>'>
<input type="text" name="role" value="<%= util.HTMLFilter.filter(role) %>">
<input type="submit" >
</form>
<br><br>
To add some data to the authenticated session, enter it here:
<form method="GET" action='<%= response.encodeURL("index.jsp") %>'>
<input type="text" name="dataName">
<input type="text" name="dataValue">
<input type="submit" >
</form>
<br><br>
<%
String dataName = request.getParameter("dataName");
if (dataName != null) {
session.setAttribute(dataName, request.getParameter("dataValue"));
}
%>
<p>The authenticated session contains the following attributes:</p>
<table>
<tr><th>Name</th><th>Value</th></tr>
<%
Enumeration<String> names = session.getAttributeNames();
while (names.hasMoreElements()) {
String name = names.nextElement();
%>
<tr><td><%= name %></td><td><%= session.getAttribute(name) %></td>
<%
}
%>
</table>
<br><br>
If you have configured this application for form-based authentication, you can
log off by clicking
<a href='<%= response.encodeURL("index.jsp?logoff=true") %>'>here</a>.
This should cause you to be returned to the login page after the redirect
that is performed.
</body>
</html>

View File

@@ -0,0 +1,38 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<html>
<head>
<title>Login Page for Examples</title>
<body bgcolor="white">
<form method="POST" action='<%= response.encodeURL("j_security_check") %>' >
<table border="0" cellspacing="5">
<tr>
<th align="right">Username:</th>
<td align="left"><input type="text" name="j_username"></td>
</tr>
<tr>
<th align="right">Password:</th>
<td align="left"><input type="password" name="j_password"></td>
</tr>
<tr>
<td align="right"><input type="submit" value="Log In"></td>
<td align="left"><input type="reset"></td>
</tr>
</table>
</form>
</body>
</html>

View File

@@ -0,0 +1,56 @@
<HTML>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<HEAD>
<title>
sessions.DummyCart Bean Properties
</title>
<BODY BGCOLOR="white">
<H2>
sessions.DummyCart Bean Properties
</H2>
<HR>
<DL>
<DT>public class <B>DummyCart</B><DT>extends Object</DL>
<P>
<HR>
<P>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0">
<TR BGCOLOR="#EEEEFF">
<TD COLSPAN=3><FONT SIZE="+2">
<B>Properties Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white">
<td align="right" valign="top" width="1%">
<FONT SIZE="-1">
String
</FONT></TD>
<TD><B>DummyCart:items</B>
<BR>
</TD>
<td width="1%">
<FONT SIZE="-1">
Multi
</FONT></TD>
</TABLE>
<HR>
</BODY>
</HTML>

View File

@@ -0,0 +1,53 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>carts</title>
</head>
<body bgcolor="white">
<font size = 5 color="#CC0000">
<form type=POST action=carts.jsp>
<BR>
Please enter item to add or remove:
<br>
Add Item:
<SELECT NAME="item">
<OPTION>Beavis & Butt-head Video collection
<OPTION>X-files movie
<OPTION>Twin peaks tapes
<OPTION>NIN CD
<OPTION>JSP Book
<OPTION>Concert tickets
<OPTION>Love life
<OPTION>Switch blade
<OPTION>Rex, Rugs & Rock n' Roll
</SELECT>
<br> <br>
<INPUT TYPE=submit name="submit" value="add">
<INPUT TYPE=submit name="submit" value="remove">
</form>
</FONT>
</body>
</html>

View File

@@ -0,0 +1,43 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<html>
<jsp:useBean id="cart" scope="session" class="sessions.DummyCart" />
<jsp:setProperty name="cart" property="*" />
<%
cart.processRequest();
%>
<FONT size = 5 COLOR="#CC0000">
<br> You have the following items in your cart:
<ol>
<%
String[] items = cart.getItems();
for (int i=0; i<items.length; i++) {
%>
<li> <% out.print(util.HTMLFilter.filter(items[i])); %>
<%
}
%>
</ol>
</FONT>
<hr>
<%@ include file ="carts.html" %>
</html>

View File

@@ -0,0 +1,34 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="carts.html"><img src="../images/execute.gif" align="right" border="0"></a><a href="../index.html"><img src="../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="carts.jsp.html">Source Code for Cart Example<font color="#0000FF"></a>
</font> </h3>
<h3><a href="DummyCart.html">Property Sheet for DummyCart
<font color="#0000FF"></a> </font> </h3>
</body>
</html>

View File

@@ -0,0 +1,30 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="foo.jsp"><img src="../images/execute.gif" align="right" border="0"></a><a href="../index.html"><img src="../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="foo.jsp.html">Source Code for the Simple Tag Example<font color="#0000FF"></a>
</font> </h3>
</body>
</html>

View File

@@ -0,0 +1,38 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<html>
<body>
<%@ taglib uri="http://tomcat.apache.org/example-taglib" prefix="eg"%>
Radio stations that rock:
<ul>
<eg:foo att1="98.5" att2="92.3" att3="107.7">
<li><%= member %></li>
</eg:foo>
</ul>
<eg:log>
Did you see me on the stderr window?
</eg:log>
<eg:log toBrowser="true">
Did you see me on the browser window as well?
</eg:log>
</body>
</html>

View File

@@ -0,0 +1,31 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="snoop.jsp"><img src="../images/execute.gif" align="right" border="0"></a><a href="../index.html"><img src="../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="snoop.jsp.html">Source Code for Request Parameters Example<font color="#0000FF">
</font></a></h3>
</body>
</html>

View File

@@ -0,0 +1,56 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<html>
<body bgcolor="white">
<h1> Request Information </h1>
<font size="4">
JSP Request Method: <%= util.HTMLFilter.filter(request.getMethod()) %>
<br>
Request URI: <%= util.HTMLFilter.filter(request.getRequestURI()) %>
<br>
Request Protocol: <%= util.HTMLFilter.filter(request.getProtocol()) %>
<br>
Servlet path: <%= util.HTMLFilter.filter(request.getServletPath()) %>
<br>
Path info: <%= util.HTMLFilter.filter(request.getPathInfo()) %>
<br>
Query string: <%= util.HTMLFilter.filter(request.getQueryString()) %>
<br>
Content length: <%= request.getContentLength() %>
<br>
Content type: <%= util.HTMLFilter.filter(request.getContentType()) %>
<br>
Server name: <%= util.HTMLFilter.filter(request.getServerName()) %>
<br>
Server port: <%= request.getServerPort() %>
<br>
Remote user: <%= util.HTMLFilter.filter(request.getRemoteUser()) %>
<br>
Remote address: <%= util.HTMLFilter.filter(request.getRemoteAddr()) %>
<br>
Remote host: <%= util.HTMLFilter.filter(request.getRemoteHost()) %>
<br>
Authorization scheme: <%= util.HTMLFilter.filter(request.getAuthType()) %>
<br>
Locale: <%= request.getLocale() %>
<hr>
The browser you are using is
<%= util.HTMLFilter.filter(request.getHeader("User-Agent")) %>
<hr>
</font>
</body>
</html>

View File

@@ -0,0 +1,36 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
<head>
<title>View Source Code</title>
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF">
<a href="choose.jsp">
<img src="../images/execute.gif" align="right" border="0"></a>
<a href="../index.html">
<img src="../images/return.gif" width="24" height="24" align="right" border="0">
</a></font>
</p>
<h3>
<a href="choose.jsp.html">Source Code for choose.jsp<font color="#0000FF"/></a>
</h3>
</body>
</html>

View File

@@ -0,0 +1,54 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<html>
<head>
<title>Tag Examples - choose</title>
</head>
<body>
<h1>Tag Plugin Examples - &lt;c:choose></h1>
<hr/>
<br/>
<a href="notes.html">Plugin Introductory Notes</a>
<br/>
<a href="howto.html">Brief Instructions for Writing Plugins</a>
<br/> <br/>
<hr/>
<br/>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:forEach var="index" begin="0" end="4">
# ${index}:
<c:choose>
<c:when test="${index == 1}">
One!<br/>
</c:when>
<c:when test="${index == 4}">
Four!<br/>
</c:when>
<c:when test="${index == 3}">
Three!<br/>
</c:when>
<c:otherwise>
Huh?<br/>
</c:otherwise>
</c:choose>
</c:forEach>
</body>
</html>

View File

@@ -0,0 +1,36 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
<head>
<title>View Source Code</title>
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF">
<a href="foreach.jsp">
<img src="../images/execute.gif" align="right" border="0"></a>
<a href="../index.html">
<img src="../images/return.gif" width="24" height="24" align="right" border="0">
</a></font>
</p>
<h3>
<a href="foreach.jsp.html">Source Code for foreach.jsp<font color="#0000FF"/></a>
</h3>
</body>
</html>

View File

@@ -0,0 +1,54 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<html>
<head>
<title>Tag Plugin Examples: forEach</title>
</head>
<body>
<h1>Tag Plugin Examples - &lt;c:forEach></h1>
<hr/>
<br/>
<a href="notes.html">Plugin Introductory Notes</a>
<br/>
<a href="howto.html">Brief Instructions for Writing Plugins</a>
<br/> <br/>
<hr/>
<br/>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page import="java.util.Vector" %>
<h3>Iterating over a range</h3>
<c:forEach var="item" begin="1" end="10">
${item}
</c:forEach>
<% Vector v = new Vector();
v.add("One"); v.add("Two"); v.add("Three"); v.add("Four");
pageContext.setAttribute("vector", v);
%>
<h3>Iterating over a Vector</h3>
<c:forEach items="${vector}" var="item" >
${item}
</c:forEach>
</body>
</html>

View File

@@ -0,0 +1,45 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
<head>
<title>Tag Plugin Implementation</title>
</head>
<body>
<h2>How to write tag plugins</h2>
<p>
To write a plugin, you'll need to download the source for Tomcat.
There are two steps:
<ol>
<li>
Implement the plugin class.<p/>
This class, which implements
<tt>org.apache.jasper.compiler.tagplugin.TagPlugin</tt>
instructs Jasper what Java codes to generate in place of the tag
handler calls.
See Javadoc for <tt>org.apache.jasper.compiler.tagplugin.TagPlugin</tt>
for details.
</li>
<li>
Create the plugin descriptor file <tt> WEB-INF/tagPlugins.xml</tt><p/>
This file
specifies the plugin classes and their corresponding tag handler
classes.
</li>
</ol>
</body>
</html>

View File

@@ -0,0 +1,36 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
<head>
<title>View Source Code</title>
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF">
<a href="if.jsp">
<img src="../images/execute.gif" align="right" border="0"></a>
<a href="../index.html">
<img src="../images/return.gif" width="24" height="24" align="right" border="0">
</a></font>
</p>
<h3>
<a href="if.jsp.html">Source Code for if.jsp<font color="#0000FF"/></a>
</h3>
</body>
</html>

View File

@@ -0,0 +1,47 @@
<%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<html>
<head>
<title>Tag Plugin Examples: if</title>
</head>
<body>
<h1>Tag Plugin Examples - &lt;c:if></h1>
<hr/>
<br/>
<a href="notes.html">Plugin Introductory Notes</a>
<br/>
<a href="howto.html">Brief Instructions for Writing Plugins</a>
<br/> <br/>
<hr/>
<br/>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<h3>Set the test result to a variable</h3>
<c:if test="${1==1}" var="theTruth" scope="page"/>
The result of testing for (1==1) is: ${theTruth}
<h3>Conditionally execute the body</h3>
<c:if test="${2>0}">
<p>It's true that (2>0)! Working.</p>
</c:if>
<c:if test="${0>2}">
<p>It's not true that (0>2)! Failed.</p>
</c:if>
</body>
</html>

View File

@@ -0,0 +1,41 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
<head>
<title>Tag Plugin Introduction</title>
</head>
<body>
<h2>Tag Plugins: Introductory Notes</h2>
<p>
Tomcat provides a framework for implementing tag plugins. The
plugins instruct Jasper, at translation time, to replace tag handler
calls with Java scriptlets.
The framework allows tag library authors to implement plugins for
their tags.
</p>
<p>
Tomcat is released with plugins for several JSTL tags. Note
that these plugins work with JSTL 1.1 as well as JSTL 1.0, though
the examples uses JSTL 1.1 and JSP 2.0.
These plugins are not complete (for instance, some item types are not
handled in &lt;c:if>).
They do serve as examples to show plugins in action (just
examine the generated Java files), and how they can be implemented.
</p>
</body>
</html>

View File

@@ -0,0 +1,31 @@
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="xml.jsp"><img src="../images/execute.gif" align="right" border="0"></a><a href="../index.html"><img src="../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
<h3><a href="xml.jsp.html">Source Code for XML syntax Example<font color="#0000FF"></a>
</font> </h3>
</body>
</html>

View File

@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
version="1.2">
<jsp:directive.page contentType="text/html"/>
<jsp:directive.page import="java.util.Date, java.util.Locale"/>
<jsp:directive.page import="java.text.*"/>
<jsp:declaration>
String getDateTimeStr(Locale l) {
DateFormat df = SimpleDateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, l);
return df.format(new Date());
}
</jsp:declaration>
<html>
<head>
<title>Example JSP in XML format</title>
</head>
<body>
This is the output of a simple JSP using XML format.
<br />
<div>Use a jsp:scriptlet to loop from 1 to 10: </div>
<jsp:scriptlet>
// Note we need to declare CDATA because we don't escape the less than symbol
<![CDATA[
for (int i = 1; i<=10; i++) {
out.println(i);
if (i < 10) {
out.println(", ");
}
}
]]>
</jsp:scriptlet>
<!-- Because I omit br's end tag, declare it as CDATA -->
<![CDATA[
<br><br>
]]>
<div align="left">
Use a jsp:expression to write the date and time in the browser's locale:
<jsp:expression>getDateTimeStr(request.getLocale())</jsp:expression>
</div>
<jsp:text>
&lt;p&gt;This sentence is enclosed in a jsp:text element.&lt;/p&gt;
</jsp:text>
</body>
</html>
</jsp:root>