Grosse MàJ

This commit is contained in:
olivier
2008-11-25 22:11:16 +01:00
parent 53195fdfcd
commit 3e719157ea
2980 changed files with 343846 additions and 0 deletions

View File

@ -0,0 +1,61 @@
<!--
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>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="servlet/CookieExample"><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>Source Code for Cookie Example<font color="#0000FF"><br>
</font> </h3>
<font color="#0000FF"></font>
<pre><font color="#0000FF">import</font> java.io.*;
<font color="#0000FF">import</font> javax.servlet.*;
<font color="#0000FF">import</font> javax.servlet.http.*;
<font color="#0000FF">public class</font> CookieExample <font color="#0000FF">extends</font> HttpServlet {
<font color="#0000FF">public void</font> doGet(HttpServletRequest request, HttpServletResponse response)
<font color="#0000FF">throws</font> IOException, ServletException
{
response.setContentType(&quot;<font color="#009900">text/html</font>&quot;);
PrintWriter out = response.getWriter();
<font color="#CC0000">// print out cookies</font>
Cookie[] cookies = request.getCookies();
for (int i = 0; i &lt; cookies.length; i++) {
Cookie c = cookies[i];
String name = c.getName();
String value = c.getValue();
out.println(name + &quot;<font color="#009900"> = </font>&quot; + value);
}
<font color="#CC0000">// set a cookie</font>
String name = request.getParameter(&quot;<font color="#009900">cookieName</font>&quot;);
if (name != null &amp;&amp; name.length() &gt; 0) {
String value = request.getParameter(&quot;<font color="#009900">cookieValue</font>&quot;);
Cookie c = new Cookie(name, value);
response.addCookie(c);
}
}
}</pre>
</body>
</html>

View File

@ -0,0 +1,50 @@
<!--
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>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="servlet/HelloWorldExample"><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>Source Code for HelloWorld Example<font color="#0000FF"><br>
</font> </h3>
<font color="#0000FF"></font>
<pre><font color="#0000FF">import</font> java.io.*;
<font color="#0000FF">import</font> javax.servlet.*;
<font color="#0000FF">import</font> javax.servlet.http.*;
<font color="#0000FF">public class</font> HelloWorld <font color="#0000FF">extends</font> HttpServlet {
<font color="#0000FF">public void</font> doGet(HttpServletRequest request, HttpServletResponse response)
<font color="#0000FF">throws</font> IOException, ServletException
{
response.setContentType(&quot;<font color="#009900">text/html</font>&quot;);
PrintWriter out = response.getWriter();
out.println(&quot;<font color="#009900">&lt;html&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;head&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;title&gt;Hello World!&lt;/title&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;/head&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;body&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;h1&gt;Hello World!&lt;/h1&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;/body&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;/html&gt;</font>&quot;);
}
}</pre>
</body>
</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,121 @@
<!--
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 public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.61 [en] (WinNT; I) [Netscape]">
<meta name="Author" content="Anil K. Vijendran">
<title>Servlet Examples</title>
</head>
<body bgcolor="#FFFFFF">
<b><font face="Arial, Helvetica, sans-serif"><font size=+2>Servlet
Examples with Code</font></font></b>
<p>This is a collection of examples which demonstrate some of the more
frequently used parts of the Servlet API. Familiarity with the Java(tm)
Programming Language is assumed.
<p>These examples will only work when viewed via an http URL. They will
not work if you are viewing these pages via a "file://..." URL. Please
refer to the <i>README</i> file provide with this Tomcat release regarding
how to configure and start the provided web server.
<p>Wherever you see a form, enter some data and see how the servlet reacts.
When playing with the Cookie and Session Examples, jump back to the Headers
Example to see exactly what your browser is sending the server.
<p>To navigate your way through the examples, the following icons will
help:
<br>&nbsp;
<table BORDER=0 CELLSPACING=5 WIDTH="85%" >
<tr VALIGN=TOP>
<td WIDTH="30"><img SRC="images/execute.gif" ></td>
<td>Execute the example</td>
</tr>
<tr VALIGN=TOP>
<td WIDTH="30"><img SRC="images/code.gif" height=24 width=24></td>
<td>Look at the source code for the example</td>
</tr>
<tr VALIGN=TOP>
<td WIDTH="30"><img SRC="images/return.gif" height=24 width=24></td>
<td>Return to this screen</td>
</tr>
</table>
<p>Tip: To see the cookie interactions with your browser, try turning on
the "notify when setting a cookie" option in your browser preferences.
This will let you see when a session is created and give some feedback
when looking at the cookie demo.
<br>&nbsp;
<table BORDER=0 CELLSPACING=5 WIDTH="85%" >
<tr VALIGN=TOP>
<td>Hello World</td>
<td VALIGN=TOP WIDTH="30%"><a href="servlet/HelloWorldExample"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP></a><a href="servlet/HelloWorldExample">Execute</a></td>
<td WIDTH="30%"><a href="helloworld.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="helloworld.html">Source</a></td>
</tr>
<tr VALIGN=TOP>
<td>Request Info</td>
<td WIDTH="30%"><a href="servlet/RequestInfoExample"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP></a><a href="servlet/RequestInfoExample">Execute</a></td>
<td WIDTH="30%"><a href="reqinfo.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="reqinfo.html">Source</a></td>
</tr>
<tr VALIGN=TOP>
<td>Request Headers</td>
<td WIDTH="30%"><a href="servlet/RequestHeaderExample"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP></a><a href="servlet/RequestHeaderExample">Execute</a></td>
<td WIDTH="30%"><a href="reqheaders.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="reqheaders.html">Source</a></td>
</tr>
<tr VALIGN=TOP>
<td>Request Parameters</td>
<td WIDTH="30%"><a href="servlet/RequestParamExample"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP></a><a href="servlet/RequestParamExample">Execute</a></td>
<td WIDTH="30%"><a href="reqparams.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="reqparams.html">Source</a></td>
</tr>
<tr VALIGN=TOP>
<td>Cookies</td>
<td WIDTH="30%"><a href="servlet/CookieExample"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP></a><a href="servlet/CookieExample">Execute</a></td>
<td WIDTH="30%"><a href="cookies.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="cookies.html">Source</a></td>
</tr>
<tr VALIGN=TOP>
<td>Sessions</td>
<td WIDTH="30%"><a href="servlet/SessionExample"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP></a><a href="servlet/SessionExample">Execute</a></td>
<td WIDTH="30%"><a href="sessions.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="sessions.html">Source</a></td>
</tr>
</table>
<p>Note: The source code for these examples does not contain all of the
source code that is actually in the example, only the important sections
of code. Code not important to understand the example has been removed
for clarity.
</body>
</html>

View File

@ -0,0 +1,49 @@
<!--
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>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="servlet/RequestHeaderExample"><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>Source Code for RequestHeader Example<font color="#0000FF"><br>
</font> </h3>
<font color="#0000FF"></font>
<pre><font color="#0000FF">import</font> java.io.*;
<font color="#0000FF">import</font> java.util.*;
<font color="#0000FF">import</font> javax.servlet.*;
<font color="#0000FF">import</font> javax.servlet.http.*;
<font color="#0000FF">public class</font> RequestHeaderExample <font color="#0000FF">extends</font> HttpServlet {
<font color="#0000FF">public void</font> doGet(HttpServletRequest request, HttpServletResponse response)
<font color="#0000FF">throws</font> IOException, ServletException
{
response.setContentType(&quot;<font color="#009900">text/html</font>&quot;);
PrintWriter out = response.getWriter();
Enumeration e = request.getHeaderNames();
while (e.hasMoreElements()) {
String name = (String)e.nextElement();
String value = request.getHeader(name);
out.println(name + &quot;<font color="#009900"> = </font>&quot; + value);
}
}
}</pre>
</body>
</html>

View File

@ -0,0 +1,68 @@
<!--
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>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="servlet/RequestInfoExample"><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>Source Code for Request Info Example<font color="#0000FF"><br>
</font> </h3>
<font color="#0000FF"></font>
<pre><font color="#0000FF">import</font> java.io.*;
<font color="#0000FF">import</font> javax.servlet.*;
<font color="#0000FF">import</font> javax.servlet.http.*;
<font color="#0000FF">public class</font> RequestInfo <font color="#0000FF">extends</font> HttpServlet {
<font color="#0000FF">public void</font> doGet(HttpServletRequest request, HttpServletResponse response)
<font color="#0000FF">throws</font> IOException, ServletException
{
response.setContentType(&quot;<font color="#009900">text/html</font>&quot;);
PrintWriter out = response.getWriter();
out.println(&quot;<font color="#009900">&lt;html&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;body&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;head&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;title&gt;Request Information Example&lt;/title&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;/head&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;body&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;h3&gt;Request Information Example&lt;/h3&gt;</font>&quot;);
out.println(&quot;<font color="#009900">Method: </font>&quot; + request.getMethod());
out.println(&quot;<font color="#009900">Request URI: </font>&quot; + request.getRequestURI());
out.println(&quot;<font color="#009900">Protocol: </font>&quot; + request.getProtocol());
out.println(&quot;<font color="#009900">PathInfo: </font>&quot; + request.getPathInfo());
out.println(&quot;<font color="#009900">Remote Address: </font>&quot; + request.getRemoteAddr());
out.println(&quot;<font color="#009900">&lt;/body&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;/html&gt;</font>&quot;);
}
<font color="#FF0000"> /**
* We are going to perform the same operations for POST requests
* as for GET methods, so this method just sends the request to
* the doGet method.
*/</font>
<font color="#0000FF">public void</font> doPost(HttpServletRequest request, HttpServletResponse response)
<font color="#0000FF">throws</font> IOException, ServletException
{
doGet(request, response);
}
}</pre>
</body>
</html>

View File

@ -0,0 +1,78 @@
<!--
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>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="servlet/RequestParamExample"><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>Source Code for Request Parameter Example<font color="#0000FF"><br>
</font> </h3>
<font color="#0000FF"></font>
<pre><font color="#0000FF">import</font> java.io.*;
<font color="#0000FF">import</font> java.util.*;
<font color="#0000FF">import</font> javax.servlet.*;
<font color="#0000FF">import</font> javax.servlet.http.*;
<font color="#0000FF">public class</font> RequestParamExample <font color="#0000FF">extends</font> HttpServlet {
<font color="#0000FF">public void</font> doGet(HttpServletRequest request, HttpServletResponse response)
<font color="#0000FF">throws</font> IOException, ServletException
{
response.setContentType(&quot;<font color="#009900">text/html</font>&quot;);
PrintWriter out = response.getWriter();
out.println(&quot;<font color="#009900">&lt;html&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;head&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;title&gt;Request Parameters Example&lt;/title&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;/head&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;body&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;h3&gt;Request Parameters Example&lt;/h3&gt;</font>&quot;);
out.println(&quot;<font color="#009900">Parameters in this request:&lt;br&gt;</font>&quot;);
if (firstName != null || lastName != null) {
out.println(&quot;<font color="#009900">First Name:</font>&quot;);
out.println(&quot;<font color="#009900"> = </font>&quot; + HTMLFilter.filter(firstName) + &quot;<font color="#009900">&lt;br&gt;</font>&quot;);
out.println(&quot;<font color="#009900">Last Name:</font>&quot;);
out.println(&quot;<font color="#009900"> = </font>&quot; + HTMLFilter.filter(lastName));
} else {
out.println(&quot;<font color="#009900">No Parameters, Please enter some</font>&quot;);
}
out.println(&quot;<font color="#009900">&lt;P&gt;</font>&quot;);
out.print(&quot;<font color="#009900">&lt;form action=\"</font>&quot;);
out.print(&quot;<font color="#009900">RequestParamExample\" </font>&quot;);
out.println(&quot;<font color="#009900">method=POST&gt;</font>&quot;);
out.println(&quot;<font color="#009900">First Name:</font>&quot;);
out.println(&quot;<font color="#009900">&lt;input type=text size=20 name=firstname&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;br&gt;</font>&quot;);
out.println(&quot;<font color="#009900">Last Name:</font>&quot;);
out.println(&quot;<font color="#009900">&lt;input type=text size=20 name=lastname&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;br&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;input type=submit&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;/form&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;/body&gt;</font>&quot;);
out.println(&quot;<font color="#009900">&lt;/html&gt;</font>&quot;);
}
<font color="#0000FF">public void</font> doPost(HttpServletRequest request, HttpServletResponse res)
<font color="#0000FF">throws</font> IOException, ServletException
{
doGet(request, response);
}
}</pre>
</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>
<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="servlet/SessionExample"><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>Source Code for Session Example<font color="#0000FF"><br>
</font> </h3>
<font color="#0000FF"></font>
<pre><font color="#0000FF">import</font> java.io.*;
<font color="#0000FF">import</font> java.util.*;
<font color="#0000FF">import</font> javax.servlet.*;
<font color="#0000FF">import</font> javax.servlet.http.*;
<font color="#0000FF">public class</font> SessionExample <font color="#0000FF">extends</font> HttpServlet {
<font color="#0000FF">public void</font> doGet(HttpServletRequest request, HttpServletResponse response)
<font color="#0000FF">throws</font> IOException, ServletException
{
response.setContentType(&quot;<font color="#009900">text/html</font>&quot;);
PrintWriter out = response.getWriter();
HttpSession session = request.getSession(true);
<font color="#CC0000">// print session info</font>
Date created = new Date(session.getCreationTime());
Date accessed = new Date(session.getLastAccessedTime());
out.println(&quot;<font color="#009900">ID </font>&quot; + session.getId());
out.println(&quot;<font color="#009900">Created: </font>&quot; + created);
out.println(&quot;<font color="#009900">Last Accessed: </font>&quot; + accessed);
<font color="#CC0000">// set session info if needed</font>
String dataName = request.getParameter(&quot;<font color="#009900">dataName</font>&quot;);
if (dataName != null &amp;&amp; dataName.length() &gt; 0) {
String dataValue = request.getParameter(&quot;<font color="#009900">dataValue</font>&quot;);
session.setAttribute(dataName, dataValue);
}
// print session contents
Enumeration e = session.getAttributeNames();
while (e.hasMoreElements()) {
String name = (String)e.nextElement();
String value = session.getAttribute(name).toString();
out.println(name + &quot; <font color="#009900">= </font>&quot; + value);
}
}
}</pre>
</body>
</html>