Welcome, my friends, in this lecture, we will conclude the first program that we started to create,
you will see the different lifecycle steps and in what order do they happen in eclipse?
So let us get to eclipse.
So this is Eclipse, and that is a start from the beginning and not project so practical, really going
to divert resources into source and control, lapse of let in in that we have the lifecycle steps.
Dajarra, this is our servlet.
We double click it and we go to.
Init method that created the method.
So here we just simply put, a printer instatement a print statement which will go into the console
and we'll see whether we are getting it when we on the subject.
Are we getting it or not?
So let's do the system.
No out.
Just out.
Alan.
Inside unit.
Civic control is.
You see this fight, OK?
We it.
Also, wee, wee, wee, first in this constructiveness and deconstructive will be called the object
will be called and the object is created, this empty constructor will with regard.
So let us also write up a little statement here to see whether the objects get create to see that first
the object gets created and then the unit method is called and we should see the same thing in the consortium.
Let's do that.
So a shortcut for system preprint in eclipse is just five sisso as white as so and control space and
you'll get these options out to standard of just click this double click this.
And you get an automatic system, it's a nifty feature of eclipse.
It's called context.
So here we are right inside object.
Conse.
And you say, OK, no, we will.
Randy Servlet will run the servlet and we'll see what has happened.
So right click then run ads run on Sova.
Yes, the same Sova.
Unfinished.
That's is automatically.
Dr..
And let us look at the concern now.
So this is the server, it has started it synchronized and now we go to the consulate.
Here is service start up in 1052 milliseconds and here it is inside object construct.
But this is what we had sent and the object.
So first, the object has been created.
The object is created.
That is why the superintendent has worked first inside the object contain it and then in it has been
called is inside in it so inside and it is coming over here.
So first the object has been created, like I told you in the lifecycle diagram, that the object is
created and then indeed discarded.
Right.
But what about DOGOOD and destroy methods?
So let us see what what about them?
First, we'll add the Dugit method.
Her real identity, so she's so controlled space.
DoubleClick says our system, not our talent, comes over here inside to get.
Control, yes.
OK, so no.
We'll restart.
So.
And beavered, again, we are running this so again on the same server.
OK, now remember, we are not getting into this set of inside object and but an insider that only happens
once when the object was created and when the object was loaded into the.
So it happens only once, but every request that you make will be a separate inside to do it.
So for this request, we are getting inside, doing it now.
I read it again.
I ran it again and I click on this silver finish and I get inside, do it again.
So for every request I get, I do get method is being called by every single request I do get to do
post would be called in, I guess, just being caught.
So for every request I do get will be hard work.
When the object is first created and a set of letters initiated initialized only then the object constructor
and the enigma only once I.
Now, finally.
Further solidified this concept, what I do is I share the sentiment, if I shut the server, the service
gets dislocated.
OK, so let's look at this subject completely.
I say stop the server.
So what has stopped?
I see, and I will start this with.
So instead of stuck to the fish and started, now I like it, now I look into the console segment,
start up in five milliseconds, I hold it as it does with the concern and let us right.
Click on this and then server.
Finish now you'll get all the three insane object and Stichter sight in it, because we shut down the
server, because we shut down the server, the object got the locator, the solid got unloaded.
So there was no there was no object in this house in the server when it was restarted.
So now the object has been created again.
The unit has happened.
This is a one time process.
And for the request that has been made or do it has been caught.
OK, finally, we'll be able to test the destroyed material.
So in discriminator, you go to the restroom after that seesaw control space, double click inside this
tray.
So when will destroy?
Because the story will be called again.
It will be called when you look at it.
You look at the soulik when the solid object has been sent to garbage collection before that this will
be caught.
So for that to happen, let us first ask what what what happens when we just do a simple request and
never finish?
OK, they start sort of a.
So you get we have restructured the set of it since you restructured the zone, you're getting inside
object constructor, we are getting inside in it.
This is a one time thing then for the request we are getting.
Dugit, you're not getting destroyed.
Instead, it is inside destroying.
So to get that, what we need to do is we need to go to the service, right.
Click and say stop.
Now go to the council.
Here, here, before stopping the service, after stopping the service, Catalina, here, you will
find inside this, right?
So we have found inside destroy before destroying the servlet.
The destroy method has been guarded and we can see it.
Right.
So this was all about the first that you want to go, right?
We will try to help solve it in the next section, which will have to do more with solid gold and typical
steps that are required to run according to get method.
So we will try to understand that in the next lecture.