[Java] Servlets
A servlet is a class which responds to a particular type of network request (most commonly an HTTP request). Servlets are usually used to implement web applications.
Servlets run in a servlet container, which handles the network side (eg. parsing HTTP request, connection handling.etc). One of the best-known source servlet containers is Tomcat.
Flow of Request
Servlets run in a servlet container, which handles the network side (eg. parsing HTTP request, connection handling.etc). One of the best-known source servlet containers is Tomcat.
Flow of Request
- Client sends HTTP request to Web Server
- Web Server forwards HTTP request to Web Container
- Web Container converts request into valid request object (because servlet cannot understand HTTP; only understands objects)
- Web container spins a thread for each request.
- All the business logic goes inside doGet() and doPost() methods inside the servlets.
- Servlet builds a Java response object and sends it to the container. It converts that to HTTP response again and send it to the client.
Comments
Post a Comment