#servlet
Posts
-
Digging into Tomcat's Source 2: The Big Picture — Server, Service, Connector and the Four Containers
A map for anyone opening the Tomcat source for the first time. We look at which class each server.xml element (Server, Service, Connector, Engine, Host) turns into, how the four containers Engine, Host, Context and Wrapper are linked as parents and children, why the connector (Coyote) and the servlet container (Catalina) are kept apart and joined by a single Adapter, and where Jasper, EL, JULI and Naming live — all checked against the real source and examples I actually ran.
-
Digging into Tomcat's Source 7: CoyoteAdapter and the Mapper — Which Servlet Gets the Request
We follow CoyoteAdapter, the bridge that carries a fully read HTTP request from Coyote into Catalina; postParseRequest(), which decodes and normalizes the URI on the way; and the order of rules the Mapper uses to pick a Host, a Context and a Wrapper. Six servlets show the mapping priorities, curl shows what happens to %2F, .. and ;jsessionid, and a request object held too long shows why RequestFacade exists.
-
Digging into Tomcat's Source 9: The Filter Chain and the Servlet Call — Until service() Runs
At the very end of the valve chain, Tomcat takes out a servlet instance, picks the filters that match this request, puts them in an array, and walks that array one step at a time until it finally calls service(). We follow this in the source, and use examples to check when a servlet's init() runs, how filter order is decided, how forward differs from include, and how an exception becomes an error page.
-
Digging into Tomcat's Source 10: Deploying a Web App — From a WAR to a Running Context
We follow in the source what happens inside Tomcat when you drop a WAR file into the webapps folder. HostConfig checks the folder every 10 seconds and creates a Context, ContextConfig merges web.xml, conf/web.xml and annotations and finds ServletContainerInitializers, and StandardContext.startInternal() wakes up SCIs, listeners, filters and servlets in a fixed order. We also look, from Tomcat's side, at where Spring's SpringServletContainerInitializer gets called.
-
Digging into Tomcat's Source 11: Sessions — How JSESSIONID Is Made and Removed
We follow, in the source, what Tomcat does behind one call to request.getSession() — where it reads the session ID, how it makes a new one, and when it throws it away. Cookies and ;jsessionid, the 32-character ID built from SecureRandom, the two kinds of expiry (on a request and on a background thread), and StandardManager saving sessions to a file across restarts, each checked with a small example.
-
Digging into Tomcat's Source 12: Async Servlets and Non-Blocking I/O — Letting Go of the Thread
A servlet that calls startAsync() returns without finishing its response, and the request thread goes back to the pool. We follow, in Tomcat's source and with examples that print thread names, the AsyncStateMachine that holds the request in the meantime, the path complete() and dispatch() take back to a container thread, the timeout check that runs once a second, and how a ReadListener works together with the Poller.
-
Digging into Tomcat's Source 13: Jasper — How a JSP Becomes a Servlet
What happens inside Tomcat the first time you request hello.jsp? We follow the Jasper source as JspServlet takes the request, reads the JSP file into a node tree, writes it out as Java source, compiles it with ecj, leaves a .class in the work directory, and then calls that class like any servlet. We open the generated .java file, and use examples to see when an edited JSP gets recompiled (development, modificationTestInterval, checkInterval).
-
Digging into Spring's Source 21: DispatcherServlet — How One Request Becomes a Response
We follow a single HTTP request through Spring MVC by reading the source of DispatcherServlet. Written for people new to Spring, it covers how the servlet sets up its own context and strategy objects at startup, and the order in which doDispatch finds a handler, calls it, and weaves in interceptors and exception handling.