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 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
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?