title: C# to Java of Http Session object
body: <p>In ASP.net, I have the following code.  I'm making a website in JSP and using Java classes.  Basically I want to incorporate the same functionality of this constructor.  </p>
  
  <p>What is Java code for the following c# code?</p>
  
  <pre><code>public class ShoppingCart
  {
      #region ListCart
  
      public List&lt;CartItem&gt; Items { get; private set; }
  
      #endregion
  
      #region CartSession
  
  
      public static readonly ShoppingCart Instance;
  
      static ShoppingCart()
      {
  
          if (HttpContext.Current.Session["ASPNETShoppingCart"] == null)
          {
              Instance = new ShoppingCart();
              Instance.Items = new List&lt;CartItem&gt;();
              HttpContext.Current.Session["ASPNETShoppingCart"] = Instance;
          }
          else
          {
              Instance = (ShoppingCart)HttpContext.Current.Session["ASPNETShoppingCart"];
          }
      }
  }
  </code></pre>