Link to servlet and execute doGet ()?

http://localhost:8080/guestbook/servlet/getMessages can query the database

/ servlet/getMessages is the URL of GetMessagesServlet. Query database function defined in doGet () in GetMessagesServlet. Why do you execute doGet () when you connect to this Servlet?

Mar.07,2021

because you are initiating a request through the access form of url, which initiates a request of type get.


in fact, this servlet specification defines the interface of this piece in the specification at the beginning, and then it is implemented by a specific WEB container (such as: TOMCAT) implementation, that is, the specific implementation of the servlet container code contains the implementation of calling the corresponding method after receiving the request. For example, if this is a get request, you will call doGet


servlet life cycle to learn about the execution sequence. Enter a URL request in the browser address bar, which is a get request.

Menu