How Does a Servlet Talk to a Servlet Container? JDBC

When a web server calls a servlet, it loads the servlet’s .class file (if it has not already been loaded) and calls one of the servlet’s methods(doGet(), doPost(), etc.). The method takes two parameters, an HttpServletRequest (request) and an HttpServletResponse (response), and uses these two classes to send content back to the user/client (a web browser). Four methods are available to servlet developers for producing content:

  • doHead(): Returns the headers identified by the request URL. This method is called by the servlet container to process a HEAD request. There may be many threads calling this method simultaneously:
  • service(): Provides an HTTP service:
  • doGet(): Retrieves the resource identified by the request URL:
  • doPost(): Sends data of unlimited length to the servlet container:

service() is the generic servlet request method. If you write your servlet using service(), you can ignore the other options. The doGet() and doPost() methods are more specialized: they are used for handling HTTP GET and POST requests. If you place your application code in doGet(), your servlet will only respond to GET requests.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

JDBC Topics