Author: remm
Date: Wed Aug 16 05:57:35 2006
New Revision: 431890
URL: http://svn.apache.org/viewvc?rev=431890&view=rev
Log:
- Note: the paths are not completely correct.
Added:
tomcat/tc6.0.x/trunk/webapps/examples/servlets/cookies.html (with props)
tomcat/tc6.0.x/trunk/webapps/examples/servlets/helloworld.html (with
props)
tomcat/tc6.0.x/trunk/webapps/examples/servlets/index.html (with props)
tomcat/tc6.0.x/trunk/webapps/examples/servlets/reqheaders.html (with
props)
tomcat/tc6.0.x/trunk/webapps/examples/servlets/reqinfo.html (with props)
tomcat/tc6.0.x/trunk/webapps/examples/servlets/reqparams.html (with props)
tomcat/tc6.0.x/trunk/webapps/examples/servlets/sessions.html (with props)
Added: tomcat/tc6.0.x/trunk/webapps/examples/servlets/cookies.html
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/servlets/cookies.html?rev=431890&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/servlets/cookies.html (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/servlets/cookies.html Wed Aug 16
05:57:35 2006
@@ -0,0 +1,60 @@
+<!--
+ Copyright 2004 The Apache Software Foundation
+
+ Licensed 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("<font
color="#009900">text/html</font>");
+ PrintWriter out = response.getWriter();
+
+ <font color="#CC0000">// print out cookies</font>
+
+ Cookie[] cookies = request.getCookies();
+ for (int i = 0; i < cookies.length; i++) {
+ Cookie c = cookies[i];
+ String name = c.getName();
+ String value = c.getValue();
+ out.println(name + "<font color="#009900"> = </font>" +
value);
+ }
+
+ <font color="#CC0000">// set a cookie</font>
+
+ String name = request.getParameter("<font
color="#009900">cookieName</font>");
+ if (name != null && name.length() > 0) {
+ String value = request.getParameter("<font
color="#009900">cookieValue</font>");
+ Cookie c = new Cookie(name, value);
+ response.addCookie(c);
+ }
+ }
+}</pre>
+</body>
+</html>
Propchange: tomcat/tc6.0.x/trunk/webapps/examples/servlets/cookies.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: tomcat/tc6.0.x/trunk/webapps/examples/servlets/helloworld.html
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/servlets/helloworld.html?rev=431890&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/servlets/helloworld.html (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/servlets/helloworld.html Wed Aug 16
05:57:35 2006
@@ -0,0 +1,49 @@
+<!--
+ Copyright 2004 The Apache Software Foundation
+
+ Licensed 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("<font
color="#009900">text/html</font>");
+ PrintWriter out = response.getWriter();
+ out.println("<font color="#009900"><html></font>");
+ out.println("<font color="#009900"><head></font>");
+ out.println("<font color="#009900"><title>Hello
World!</title></font>");
+ out.println("<font color="#009900"></head></font>");
+ out.println("<font color="#009900"><body></font>");
+ out.println("<font color="#009900"><h1>Hello
World!</h1></font>");
+ out.println("<font color="#009900"></body></font>");
+ out.println("<font color="#009900"></html></font>");
+ }
+}</pre>
+</body>
+</html>
Propchange: tomcat/tc6.0.x/trunk/webapps/examples/servlets/helloworld.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: tomcat/tc6.0.x/trunk/webapps/examples/servlets/index.html
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/servlets/index.html?rev=431890&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/servlets/index.html (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/servlets/index.html Wed Aug 16
05:57:35 2006
@@ -0,0 +1,120 @@
+<!--
+ Copyright 2004 The Apache Software Foundation
+
+ Licensed 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>
+<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>
+<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>
Propchange: tomcat/tc6.0.x/trunk/webapps/examples/servlets/index.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: tomcat/tc6.0.x/trunk/webapps/examples/servlets/reqheaders.html
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/servlets/reqheaders.html?rev=431890&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/servlets/reqheaders.html (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/servlets/reqheaders.html Wed Aug 16
05:57:35 2006
@@ -0,0 +1,48 @@
+<!--
+ Copyright 2004 The Apache Software Foundation
+
+ Licensed 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("<font
color="#009900">text/html</font>");
+ PrintWriter out = response.getWriter();
+ Enumeration e = request.getHeaderNames();
+ while (e.hasMoreElements()) {
+ String name = (String)e.nextElement();
+ String value = request.getHeader(name);
+ out.println(name + "<font color="#009900"> = </font>" +
value);
+ }
+ }
+}</pre>
+</body>
+</html>
Propchange: tomcat/tc6.0.x/trunk/webapps/examples/servlets/reqheaders.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: tomcat/tc6.0.x/trunk/webapps/examples/servlets/reqinfo.html
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/servlets/reqinfo.html?rev=431890&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/servlets/reqinfo.html (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/servlets/reqinfo.html Wed Aug 16
05:57:35 2006
@@ -0,0 +1,67 @@
+<!--
+ Copyright 2004 The Apache Software Foundation
+
+ Licensed 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("<font
color="#009900">text/html</font>");
+ PrintWriter out = response.getWriter();
+ out.println("<font color="#009900"><html></font>");
+ out.println("<font color="#009900"><body></font>");
+ out.println("<font color="#009900"><head></font>");
+ out.println("<font color="#009900"><title>Request
Information Example</title></font>");
+ out.println("<font color="#009900"></head></font>");
+ out.println("<font color="#009900"><body></font>");
+ out.println("<font color="#009900"><h3>Request Information
Example</h3></font>");
+ out.println("<font color="#009900">Method: </font>" +
request.getMethod());
+ out.println("<font color="#009900">Request URI: </font>" +
request.getRequestURI());
+ out.println("<font color="#009900">Protocol: </font>" +
request.getProtocol());
+ out.println("<font color="#009900">PathInfo: </font>" +
request.getPathInfo());
+ out.println("<font color="#009900">Remote Address: </font>"
+ request.getRemoteAddr());
+ out.println("<font color="#009900"></body></font>");
+ out.println("<font color="#009900"></html></font>");
+ }
+
+<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>
Propchange: tomcat/tc6.0.x/trunk/webapps/examples/servlets/reqinfo.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: tomcat/tc6.0.x/trunk/webapps/examples/servlets/reqparams.html
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/servlets/reqparams.html?rev=431890&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/servlets/reqparams.html (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/servlets/reqparams.html Wed Aug 16
05:57:35 2006
@@ -0,0 +1,77 @@
+<!--
+ Copyright 2004 The Apache Software Foundation
+
+ Licensed 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("<font
color="#009900">text/html</font>");
+ PrintWriter out = response.getWriter();
+ out.println("<font color="#009900"><html></font>");
+ out.println("<font color="#009900"><head></font>");
+ out.println("<font color="#009900"><title>Request
Parameters Example</title></font>");
+ out.println("<font color="#009900"></head></font>");
+ out.println("<font color="#009900"><body></font>");
+ out.println("<font color="#009900"><h3>Request Parameters
Example</h3></font>");
+ out.println("<font color="#009900">Parameters in this
request:<br></font>");
+ if (firstName != null || lastName != null) {
+ out.println("<font color="#009900">First Name:</font>");
+ out.println("<font color="#009900"> = </font>" +
HTMLFilter.filter(firstName) + "<font
color="#009900"><br></font>");
+ out.println("<font color="#009900">Last Name:</font>");
+ out.println("<font color="#009900"> = </font>" +
HTMLFilter.filter(lastName));
+ } else {
+ out.println("<font color="#009900">No Parameters, Please
enter some</font>");
+ }
+ out.println("<font color="#009900"><P></font>");
+ out.print("<font color="#009900"><form action=\"</font>");
+ out.print("<font color="#009900">RequestParamExample\"
</font>");
+ out.println("<font color="#009900">method=POST></font>");
+ out.println("<font color="#009900">First Name:</font>");
+ out.println("<font color="#009900"><input type=text size=20
name=firstname></font>");
+ out.println("<font color="#009900"><br></font>");
+ out.println("<font color="#009900">Last Name:</font>");
+ out.println("<font color="#009900"><input type=text size=20
name=lastname></font>");
+ out.println("<font color="#009900"><br></font>");
+ out.println("<font color="#009900"><input
type=submit></font>");
+ out.println("<font color="#009900"></form></font>");
+ out.println("<font color="#009900"></body></font>");
+ out.println("<font color="#009900"></html></font>");
+ }
+
+ <font color="#0000FF">public void</font> doPost(HttpServletRequest
request, HttpServletResponse res)
+ <font color="#0000FF">throws</font> IOException, ServletException
+ {
+ doGet(request, response);
+ }
+}</pre>
+</body>
+</html>
Propchange: tomcat/tc6.0.x/trunk/webapps/examples/servlets/reqparams.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: tomcat/tc6.0.x/trunk/webapps/examples/servlets/sessions.html
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/servlets/sessions.html?rev=431890&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/servlets/sessions.html (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/servlets/sessions.html Wed Aug 16
05:57:35 2006
@@ -0,0 +1,69 @@
+<!--
+ Copyright 2004 The Apache Software Foundation
+
+ Licensed 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("<font
color="#009900">text/html</font>");
+ 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("<font color="#009900">ID </font>" +
session.getId());
+ out.println("<font color="#009900">Created: </font>" +
created);
+ out.println("<font color="#009900">Last Accessed: </font>" +
accessed);
+
+ <font color="#CC0000">// set session info if needed</font>
+
+ String dataName = request.getParameter("<font
color="#009900">dataName</font>");
+ if (dataName != null && dataName.length() > 0) {
+ String dataValue = request.getParameter("<font
color="#009900">dataValue</font>");
+ 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 + " <font color="#009900">= </font>" +
value);
+ }
+ }
+}</pre>
+</body>
+</html>
Propchange: tomcat/tc6.0.x/trunk/webapps/examples/servlets/sessions.html
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]