The int method is called only once. It is called only when the data type is created, and not called for any user requests afterwards. So, it is used for one-time to initialize the data, just as with the init method of applets.
The data is normally created when a user first invokes a URL corresponding to the servlet, but you can also specify that the data be loaded when the server is first started.
When a user invokes a servlet, a single instance of each servlet gets created, with each user request resulting in a new thread that is handed off to doGet or doPost as appropriate. The init() method simply creates or loads some data that will be used throughout the life of the servlet.
The init method definition looks like this:
ex:
public void init() throws DataException {
// Initialization code...
}
The service() Method The service() method is the main method to perform
The data is normally created when a user first invokes a URL corresponding to the servlet, but you can also specify that the data be loaded when the server is first started.
When a user invokes a servlet, a single instance of each servlet gets created, with each user request resulting in a new thread that is handed off to doGet or doPost as appropriate. The init() method simply creates or loads some data that will be used throughout the life of the servlet.
The init method definition looks like this:
ex:
public void init() throws DataException {
// Initialization code...
}
The service() Method The service() method is the main method to perform
Nice one
ReplyDeleteTnks bro
DeleteSuper bro
ReplyDeleteMake on loops bro
ReplyDelete