GeeCON Prague 2014*
The moose likes Servlets and the fly likes Call back methods ..what happens in background ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "Call back methods ..what happens in background ?" Watch "Call back methods ..what happens in background ?" New topic
Author

Call back methods ..what happens in background ?

adil qureshi
Ranch Hand

Joined: Jul 11, 2008
Posts: 48
We all know that all servlet life cycle methods are callback , even in AJAX but i want to know what exactly happens in background ?


SCJP 1.5,SCWCD 1.5
shivendra tripathi
Ranch Hand

Joined: Aug 26, 2008
Posts: 263
Callback methods follows design principle "Don't call me I will call you back". Under the hood, generally these call back methods are declared in interface. We need to implement the interface and register the implementation. So whenever (in case of servlet) container call a particular callback method respective implementation will be called.


SCJP 1.5(97%) My Blog
adil qureshi
Ranch Hand

Joined: Jul 11, 2008
Posts: 48
shivendra tripathi wrote:Callback methods follows design principle "Don't call me I will call you back". Under the hood, generally these call back methods are declared in interface. We need to implement the interface and register the implementation. So whenever (in case of servlet) container call a particular callback method respective implementation will be called.


so is it some thing like thread wait and notify happening in background or what because i cant create a picture that how container waits for a callback it must be maintaining some kind of temporary thing like stack there....
shivendra tripathi
Ranch Hand

Joined: Aug 26, 2008
Posts: 263
Callback means you have done some implementation and want someone (in this case container) to call this when needed. Say, you have written MyServlet class which implements Servlet and you have registered MyServlet in web.xml corresponding to url pattern /MyServlet. Now your job is done. And when url with pattern /MyServlet will come to the server your implementation(say, doPost) will be called back by the server.
adil qureshi
Ranch Hand

Joined: Jul 11, 2008
Posts: 48
shivendra tripathi wrote:Callback means you have done some implementation and want someone (in this case container) to call this when needed. Say, you have written MyServlet class which implements Servlet and you have registered MyServlet in web.xml corresponding to url pattern /MyServlet. Now your job is done. And when url with pattern /MyServlet will come to the server your implementation(say, doPost) will be called back by the server.


oops dear shivendra i uderstand this basic thing please see i want to know the background operation what happens in background not the meaning..... i have already written in my question...thanks in advance
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1

Hi,

I'm not sure to what extent of 'what happens in the background' you are interested in. Hope I'm able to give a right start.

In short: Callback methods are methods that get executed as a result of life-cycle events.

The implementation is usually through implementation of Interfaces. To my understanding when an application is deployed on the server, the classes which act as listeners for the events get registered. Hence the server is aware of the listeners and the events for which they have registered for. So Later when these life-cycle events occur the server invokes the corresponding call-back method associated with the event.

Does this give you a vague idea of the concept?

Cheers,
Raj.
 
GeeCON Prague 2014
 
subject: Call back methods ..what happens in background ?