O'Reilly logo

MySQL™ and JSP™ Web Applications: Data-Driven Programming Using Tomcat and MySQL by James Turner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Looking at an Example Servlet

Servlets are conceptually simple. You configure your Web server to map a certain URL path to a Java class (different servers do this differently). The Java class needs to extend HttpServlet and handle one of several methods: doGet, doPost, doPut, or doDelete. (doGet or doPost are used most commonly.)

These messages reflect the various ways that servlets are invoked by a GET, POST, PUT, or DELETE HTTP request from a client (although DELETE is rare). The servlet is responsible for setting the mime type, error code, cookies, and other status information about the request, as well as returning the content.

Let's say that the path /baseballstats has been mapped to the class BaseBallStatServlet. This is a class that knows ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required