Notes
Tomcat Architecture
Key Components
- Connector (Coyote)
- Accepts web requests from clients
- Handles HTTP protocol communication
- Web Container (Catalina)
- Processes servlet requests
- Manages servlet lifecycle
- Contains servlet engine
- JSP Container (Jasper)
- Handles JSP processing
- Converts JSP to servlets
- Web Applications
- Applications running within Tomcat
Thread Model
- Thread Pool Creation: Web container creates a collection of threads during startup (executor thread pool)
- Request Processing:
- Each request to connector gets a thread assigned from the pool
- Thread processes the request
- Upon completion, thread returns back to pool
- Configuration: Maximum number of threads in pool can be configured in server.xml
Request Processing Flow
- Bootstrap: Main method starts the server
- URL Mapping: Maps incoming requests to appropriate servlets
- Servlet Object: Created on first request (singleton pattern)
- Response Generation: doXxx() methods generate response
- HTTP Response: Sent back to client
Java Servlets
Servlet Definition
- Java class executed in web server when request is received from client