Questionsforum
What is difference between init() and init(ServletConfig sc) ?

What is difference between init() and init(ServletConfig sc) ?



On 2014-06-25 07:53:31.0
hablu


init() is given for the developer purpose and init(ServletConfig sc) is for the web container purpose.



On 2014-06-25 09:39:37.0
sushant

How can you say that init() is for development purpose and init(ServletConfig sc) is for container purpose ? Can you explain it ?



On 2014-06-25 10:05:22.0
hablu

init(ServletConfig sc) will be called internally by the container so that what information we configured using the tag in the web.xml , must be initialized with that parameter. So its a container responsibility, so even if we are overriding means we are responsible to take care of ServletConfig object initialization with the configured parameter in the tag. So its is not recommendable to override the init(ServletConfig sc) method in out servlet class.

init() is written inside the init(ServletConfig sc) method that means we can override and write the code to be executed at the time of initializing the ServletConfig object by the Container.

**init( ServletConfig sc) {

     this.config=config; 
    init() ; 
}**


On 2014-06-25 10:31:06.0
sushant

copyright@questionsforum.net