Lesson 26: Programming with Servlets
Yakov Fain · 2015
A servlet is a Java class written by certain rules and deployed in a Java EE–compliant servlet container of one's choice. The client program can be a lightweight HTML/JavaScript, a heavyweight applet, or a Swing or JavaFX program. This chapter uses the most popular means of web communication: Web browsers talk to servlets using HTTP, which stands for Hypertext Transfer Protocol. All examples in the chapter work in any servlet container supporting the Servlet 3.1 specification. The chapter uses a full application server GlassFish, which may be an overkill if the application only needs the servlet support. Every Java EE application server comes with a servlet container. One servlet can serve multiple users, so the chapter reviews the entire process of client-servlet communication. Java Servlets run in a container, which automatically spawns a new thread for every client's request without requiring one to do any thread programming.