This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push:
new 09b54e6 Add session attribute support to the authentication example
09b54e6 is described below
commit 09b54e62c0c10218763c78a3df6541ef002df8ee
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Nov 28 09:26:55 2019 +0000
Add session attribute support to the authentication example
Primarily to demonstrate session persistence across restarts for
authenticated sessions.
---
webapps/docs/changelog.xml | 5 ++++
webapps/examples/jsp/security/protected/index.jsp | 30 +++++++++++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index e738239..2ab8af7 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -100,6 +100,11 @@
of the <code>Connector</code> in the documentation web application.
(markt)
</fix>
+ <add>
+ Add the ability to set and display session attributes in the JSP FORM
+ authentication example to demonstrate session persistence across
+ restarts for authenticated sessions. (markt)
+ </add>
</changelog>
</subsection>
<subsection name="Other">
diff --git a/webapps/examples/jsp/security/protected/index.jsp
b/webapps/examples/jsp/security/protected/index.jsp
index eacf27a..31122eb 100644
--- a/webapps/examples/jsp/security/protected/index.jsp
+++ b/webapps/examples/jsp/security/protected/index.jsp
@@ -14,6 +14,7 @@
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();
@@ -72,6 +73,35 @@ enter it here:
</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>.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]