code: public void doPost(HttpServletRequest request,
                         HttpServletResponse response) 
          throws ServletException, IOException
      {
          HttpSession session = request.getSession(false);
          String action = request.getParameter("Action");
          String name =  request.getParameter("Name");
          String value =  request.getParameter("Value");
          String age =  request.getParameter("MaxAge");
  
          String nextUrl = getURI(request)+"?R="+redirectCount++;
          if (action.equals("New Session"))
          {   
              session = request.getSession(true);
          }
          else 
          if (session!=null)
          {
              if (action.equals("Invalidate"))
                  session.invalidate();
              else if (action.equals("Set"))
              {   
                  session.setAttribute(name,value);
                  try
                  {
                      int m = Integer.parseInt(age);
                      session.setMaxInactiveInterval(m);
                  }
                  catch(Exception e)
                  {
                      LogSupport.ignore(log,e);
                  }
              }
              else if (action.equals("Remove"))
                  session.removeAttribute(name);
          }
  
          String encodedUrl=response.encodeRedirectURL(nextUrl);
          response.sendRedirect(encodedUrl);
          
      }
docs: /* ------------------------------------------------------------