Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question Regarding Destroy Method  RSS feed

 
Akhilesh Yadav
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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().
 
Akhilesh Yadav
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Raghavan Muthu
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rahul,

you stole my words
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Raghavan Muthu:
Rahul,

you stole my words


I think I have stolen couple of times before also.
 
Raghavan Muthu
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you did

It shows we are in sync and on track.. Is it?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!