Skip to content

Commit e7d4573

Browse files
committed
docs(notes): add Spring Session and server detection guide
1 parent 4b3b607 commit e7d4573

File tree

3 files changed

+77
-2
lines changed

3 files changed

+77
-2
lines changed

_posts/en/2025-01-11-notes-en.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ generated: false
77
translated: false
88
---
99

10-
These 2126 notes are primarily generated by AI chatbots. I used them to summarize key points and will walk through them to enhance my understanding.
10+
These 2127 notes are primarily generated by AI chatbots. I used them to summarize key points and will walk through them to enhance my understanding.
1111

1212
* [AI Model Context Window Capacities](/notes/2025-09-03-ai-model-context-window-en)
1313
* [Alphabet Hits $186.66B in H1 2025](/notes/2025-09-03-alphabet-h1-2025-revenue-en)
@@ -29,6 +29,7 @@ These 2126 notes are primarily generated by AI chatbots. I used them to summariz
2929
* [Nvidia Hits $90.8B in H1 2026](/notes/2025-09-03-nvidia-90-8b-h1-2026-en)
3030
* [Standard Chartered H1 2025 Growth and Workforce](/notes/2025-09-03-sc-h1-2025-growth-workforce-en)
3131
* [Single-Entry Endorsement Extension for Hong Kong](/notes/2025-09-03-single-entry-hongkong-extension-en)
32+
* [Spring Session, JSESSIONID, and Server Detection](/notes/2025-09-03-spring-session-jsessionid-detection-en)
3233
* [Best Models for Transcript Cleanup Guide](/notes/2025-09-03-transcript-cleanup-models-en)
3334
* [The Layers and Meaning of Trust](/notes/2025-09-03-trust-layers-meaning-en)
3435
* [AI Model Context Window Comparison 2025](/notes/2025-09-02-ai-model-context-2025-en)
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
title: Spring Session, JSESSIONID, and Server Detection
3+
lang: en
4+
layout: post
5+
audio: false
6+
translated: false
7+
generated: true
8+
image: false
9+
---
10+
11+
Let’s break this into two parts: how **Spring Session/JSESSIONID** works, and how to tell whether Spring is running on **Tomcat or Netty**.
12+
13+
---
14+
15+
## 1. How Spring Session and `JSESSIONID` Work
16+
17+
* **JSESSIONID** is the standard HTTP session identifier used by servlet containers (Tomcat, Jetty, Undertow, etc.).
18+
* When a client makes the first request that requires a session, the container (or Spring Session if you use it) generates a random session ID, stores session data on the server, and sends the ID back to the client in a `Set-Cookie` header.
19+
* The client includes this `JSESSIONID` cookie on subsequent requests, allowing the server to find the correct session.
20+
* By default, the session data is stored **in the servlet container’s memory**. For example:
21+
22+
* Tomcat stores sessions in memory (unless you configure persistence).
23+
* If you use **Spring Session**, session storage can be externalized (Redis, JDBC, Hazelcast, etc.), while still using the `JSESSIONID` cookie to identify users.
24+
* Spring Security and other Spring features rely on this session mechanism for authentication and state management.
25+
26+
---
27+
28+
## 2. How to Know Whether Spring Uses Tomcat or Netty
29+
30+
Spring Boot can run with different embedded servers:
31+
32+
* **Tomcat** (default for Spring Boot starter-web)
33+
* **Jetty** (if you swap dependencies)
34+
* **Undertow** (alternative servlet container)
35+
* **Netty** (used by Spring WebFlux, not servlet-based)
36+
37+
### Ways to Check:
38+
39+
1. **Look at your dependencies**
40+
41+
* If your `pom.xml` or `build.gradle` includes `spring-boot-starter-web`, it uses **Tomcat** by default.
42+
* If it includes `spring-boot-starter-webflux`, it uses **Netty** by default.
43+
44+
2. **Check startup logs**
45+
46+
* When the app starts, Spring Boot logs the embedded server.
47+
* Example (Tomcat):
48+
49+
```
50+
Tomcat started on port(s): 8080 (http)
51+
```
52+
* Example (Netty):
53+
54+
```
55+
Netty started on port(s): 8080
56+
```
57+
58+
3. **Check runtime classes**
59+
60+
* In code or via actuator, check what server classes are loaded.
61+
* Tomcat classes start with `org.apache.catalina.`
62+
* Netty classes start with `io.netty.`
63+
64+
---
65+
66+
✅ **Summary**:
67+
68+
* `JSESSIONID` is just the cookie pointing to a server-side session, managed by Tomcat (default) or by Spring Session (Redis/DB).
69+
* You can tell whether Spring uses **Tomcat or Netty** by checking dependencies, startup logs, or runtime classes.
70+
71+
---
72+
73+
Do you want me to also explain **how session handling differs between Spring MVC (Tomcat) and Spring WebFlux (Netty)**? That’s where the distinction matters most.

original/2025-01-11-notes-en.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ generated: false
77
translated: false
88
---
99

10-
These 2126 notes are primarily generated by AI chatbots. I used them to summarize key points and will walk through them to enhance my understanding.
10+
These 2127 notes are primarily generated by AI chatbots. I used them to summarize key points and will walk through them to enhance my understanding.
1111

1212
* [AI Model Context Window Capacities](/notes/2025-09-03-ai-model-context-window-en)
1313
* [Alphabet Hits $186.66B in H1 2025](/notes/2025-09-03-alphabet-h1-2025-revenue-en)
@@ -29,6 +29,7 @@ These 2126 notes are primarily generated by AI chatbots. I used them to summariz
2929
* [Nvidia Hits $90.8B in H1 2026](/notes/2025-09-03-nvidia-90-8b-h1-2026-en)
3030
* [Standard Chartered H1 2025 Growth and Workforce](/notes/2025-09-03-sc-h1-2025-growth-workforce-en)
3131
* [Single-Entry Endorsement Extension for Hong Kong](/notes/2025-09-03-single-entry-hongkong-extension-en)
32+
* [Spring Session, JSESSIONID, and Server Detection](/notes/2025-09-03-spring-session-jsessionid-detection-en)
3233
* [Best Models for Transcript Cleanup Guide](/notes/2025-09-03-transcript-cleanup-models-en)
3334
* [The Layers and Meaning of Trust](/notes/2025-09-03-trust-layers-meaning-en)
3435
* [AI Model Context Window Comparison 2025](/notes/2025-09-02-ai-model-context-2025-en)

0 commit comments

Comments
 (0)