Link to home
Start Free TrialLog in
Avatar of she1
she1

asked on

•Servlet Callback method ??

•why we say that the followings are Servlet Callback method ?
–doGet
–doPost
–Init
–Destroy

why we use the word "callback".

thanks
Avatar of rama_krishna580
rama_krishna580
Flag of United States of America image

Hi,

A callback method is a method intended to be passed as a parameter. The callee can then call the passed method asynchronously and with whatever parameters it deems appropriate. Callbacks are often used in event handling code.

R.K
Avatar of damonf
damonf

as RK says, a callback method is designed to be called asynchronously.  That is, if object A owns method callback(), and object A enlists object B to perform some work, object B may later call a.callback() with the result of the work.  Object A does not need to maintain a reference to B for this to happen.

doGet and doPost are callbacks because any HTTP client can call them any time.  Init() and destroy() are callbacks because the container can call them anytime if it wishes to start and stop the servlet.  Actually doGet and doPost are really called by the container as well (in reaction to the client's HTTP request).  But they still can be called any time.
ASKER CERTIFIED SOLUTION
Avatar of fschutte
fschutte

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial