This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Servlets and the fly likes Question Regarding Destroy Method Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Question Regarding Destroy Method" Watch "Question Regarding Destroy Method" New topic
Author

Question Regarding Destroy Method

Akhilesh Yadav
Ranch Hand

Joined: Apr 04, 2006
Posts: 46
please answer the Following Questwions

1) if I directly close the browser in which servlet in running at that time will my Destroy Method willb called ?

2) if my server crashes willtht time Destroy method will be called ?

3) As soon as visit any webpage does session gets Automatically started
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2300
Originally posted by Akhilesh Yadav:
please answer the Following Questwions
1) if I directly close the browser in which servlet in running at that time will my Destroy Method willb called ?


No.Its a callback method and part of the servlet lifecycle.When you bring down the server , the container will call the destroy method.Nothing to do with browser closing.

Originally posted by Akhilesh Yadav:

2) if my server crashes willtht time Destroy method will be called ?


During server crash , the destroy method will not be called.

Originally posted by Akhilesh Yadav:
3) As soon as visit any webpage does session gets Automatically started


No , Container creates the session , but you have to initiate the process by calling request.getSession().


Rahul Bhattacharjee
LinkedIn - Blog
Akhilesh Yadav
Ranch Hand

Joined: Apr 04, 2006
Posts: 46
Hi Rahul thnks for the Reply but i have some doubts still
1)What do you mean by callback methods ?
2)As you said we have to intiate session by request.session() is there any Difference between HttpSession session = request.HttpSession();
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2300
Originally posted by Akhilesh Yadav:
Hi Rahul thnks for the Reply but i have some doubts still
1)What do you mean by callback methods ?
2)As you said we have to intiate session by request.session() is there any Difference between HttpSession session = request.HttpSession();


CAllback methods are to be called by the container , not to be called by the user code.

request.HttpSession() ; there is nothing like this.
You can check the javadoc of servler api for more and detail information.
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3327

Hi Akilesh,


1)What do you mean by callback methods ?


The call back methods are methods which are called by the containers or underlying program which knows the best way of dealing with it.

Mainly the lifecycle methods are called as callback methods.


2)As you said we have to intiate session by request.session() is there any Difference between HttpSession session = request.HttpSession();


I think there is only one method called request.getSession() and not HttpSession. Just check the API.

HtH.


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3327

Rahul,

you stole my words
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2300
Originally posted by Raghavan Muthu:
Rahul,

you stole my words


I think I have stolen couple of times before also.
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3327

Yes you did

It shows we are in sync and on track.. Is it?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question Regarding Destroy Method
 
Similar Threads
Questions about the servlet lifecycle methods
when is destroy called
destroy() method
how to test destroy() in a servlet
When is destroy of servlets exaclty called