Session Servlet

This servlet demonstrates the use of HTTP sessions. You can add or delete named values to a session. The same session can be retrieved next time the user visits the page via a browser cookie. Use this form to see your additions and deletions at work. Check the code to see how adding and deleting session name/value pairs works.

<% if (request.getParameter("AddValue") != null) { session.putValue("SessionServlet." + request.getParameter("NameField"), request.getParameter("ValueField")); } else if (request.getParameter("DeleteValue") != null) { session.removeValue("SessionServlet." + request.getParameter("NameField")); } %>
<% String[] sessionNames = session.getValueNames(); if (sessionNames != null) { for (int index = 0; index < sessionNames.length; index++) { %> <% } } %>
Session
Name Value
<%= sessionNames[index] %> <%= session.getValue(sessionNames[index]) %>

Name to add/delete Value

Copyright (c) 1999 by BEA Systems, Inc. All Rights Reserved.