From the course: Java EE: Servlets and JavaServer Pages (JSP)

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using the servlet life cycle

Using the servlet life cycle

From the course: Java EE: Servlets and JavaServer Pages (JSP)

Start my 1-month free trial

Using the servlet life cycle

- [Instructor] Now let's take a look at the servlet lifecycle from the code perspective. In one of the previous videos, we had written out the home servlet and done the configuration of this inside web.xml. We're going to use the same servlet for exhibiting the lifecycle of the servlet. Now, let's first understand the configuration I have written out a home servlet which extends the HTTP servlet and inside the web xml file I have done the configuration for it. That's the servlet tag for the home servlet and there are to URL patterns that I have defined for the servlet. You can do this. You can have multiple URL patterns defined for exactly the same servlet. But please note that one URL pattern cannot point to two different servlets. Right. Let's come back to home servlet. And now we know that the lifecycle methods are typically init, service, and destroy, out of which service must never be overwritten because it's already implemented in the HTTP servlet class, but init and destroy…

Contents