Overview

State Management Approaches

Client-Side State Management

  1. Cookie
  2. QueryString
  3. Hidden Form Fields
  4. HTML5 Storage (SessionStorage and LocalStorage)

Server-Side State Management

  1. HttpSession
  2. ServletContext (Application)
  3. ServletRequest

Client-Side State Management

1. Cookies

Definition: Text information in key-value pairs maintained at client browser

Creating and Sending Cookies

// Create cookie
Cookie c = new Cookie("key", "value");
resp.addCookie(c);

Receiving Cookies from Client