JSP Session Parameter Rewrite : Session « JSP « Java

JSP Session Parameter Rewrite

<%@ page import="java.util.*" %>
  // add parameter to session
  String name = request.getParameter("name");
  String value = request.getParameter("value");
  if (name!=null && value!=null && name.length()>0) {
  Date lastVisit = (Date)session.getAttribute("lastVisit");
  Date thisVisit = new Date();
    <TITLE>Session List</TITLE>
    <H1>Session List</H1>
    Last visit: <%= lastVisit %><BR>
    This visit: <%= thisVisit %><BR>
    Session ID: <%= session.getId() %><BR>
    Session max interval: <%= session.getMaxInactiveInterval() %><BR>

    <H2>Session parameters</H2>
      Enumeration enum = session.getAttributeNames();
      while (enum.hasMoreElements()) {
        String attribute = (String) enum.nextElement();

    <H2>New session parameter</H2>
<% String url = response.encodeURL("session-rewrite"); %>
    <P>Form URL '<%= url %>'</P>
    <FORM ACTION='<%= url %>'>
        <P>Name: <INPUT TYPE='TEXT' NAME='name'></P>
        <P>Value: <INPUT TYPE='TEXT' NAME='value'></P>
      <INPUT TYPE='SUBMIT' VALUE='Add new value'>

JSP-Session-Parameter-Rewrite.zip( 89 k)

Related examples in the same category

1.JSP: display a session info
2.JSP New Session Parameter
3.Jsp Session Cart
4.Use Session Jsp
5.Jsp Using Bean Scope Session
6.Print the request headers and the session attributes
7.Using Sessions to Track Users
8.Sessions disabled
9.Duplicated session varaibles
10.JSP: view session
11.JSP and session
12.JSP and session 2
13.JSP session counter