clientmakes a request to theserverserverprocesses the request and sends a response to theclient- After responding, the connection is released >>
STATELESS- The connection is released to reduce resource waste from persistent connections
- However, problems arise when the
clientandserverneed to maintain a connection state (ex. storing login info, etc.) - So Cookie and Session are used when information needs to be maintained on a per-
clientbasis!!
- However, problems arise when the
- The connection is released to reduce resource waste from persistent connections
| Session | Cookie | |
|---|---|---|
| Type | javax.servlet.http.HttpSession (interface) |
javax.servlet.http.Cookie (Class) |
| Storage Location | Stored as Object in server memory(can reference user-defined classes) |
Stored as file on the client's computer |
| Storage Format | Any Object is possible (typically Dto, List, etc.) |
String format since stored as a file |
| Usage Examples | User info on Log-In / Shopping cart | Recently viewed list / ID saving (auto-login) / 'Don't show again today' in pop-up menus |
- Commonalities
- Stored globally, so accessible from all JSPs within the project
- Managed in Map format, so duplicate
key valuesare not allowed
