View Single Post
Team Leader
23Dec2006,12:21  
pradeep's Avatar
Here is an example code to use Sessions in JSP.

Code: JSP
<%@ page import="java.util.Enumeration" %>
<%!
  private static final String textname = "text";
  private static final String countname = "counter";
%>
<%
  Integer count = (Integer) session.getAttribute (countname);
  if (count == null)
    count = new Integer (0);
  String text = request.getParameter (textname);
  if (text == null)
    text = (String) session.getAttribute (textname);
  else
    {
      session.setAttribute (textname, text);
      count = new Integer (count.intValue () + 1);
      session.setAttribute (countname, count);
    }
%>