Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question Regarding Destroy Method

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rahul,

you stole my words
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you did

It shows we are in sync and on track.. Is it?
 
Water proof donuts! Eat them while reading this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic