Sessions

   session.setAttribute("name","Fred Flintstone");  //   sets a string object to the attribute called "name"
   String name = (String)session.getAttribute("name");
     session.setMaxInactiveInterval(600);   // timeout and destroy the session and its attributes after 10 minutes

<jsp:useBean id="course" class="registrarbeans.Course" scope ="session" />

     replaces the following seqence.

registrarbeans.Course course = (registrarbeans.Course)session.getAttribute("course");   
if(course == null)  // new sesssion, just create a course
{
  course = new registrarbeans.Course();
  session.setAttribute("course", course);
 }

Java classes and sessions
          <%@ page import="registrarbeans.*"%>
registrarbeans.ShoppingCart cart = new  registrarbeans.ShoppingCart();

onlinecompany.ShoppingCart cart = (onlinecompany.ShoppingCart)session.getAttribute("Cart");     // retrieve object
if(cart == null)  // See if object exists, if not, then create one
{
  cart = new ShoppingCart();
  session.setAttribute("Cart", cart);
 }
         <jsp:useBean id="cart" class="registrarbeans.ShoppingCart" scope ="session" />  


 synchronized(session)  // lock the session object
{
  
} // release the lock