Answer Posted / bhavani
webcontainer loads the servlet from web application after
that container invokes public void init() method.the
purpose of init( ) function is some parametera are
requried to instantiate servlet class instance variables(
the parameters are driverclass,url,pass etc) these
variables are called as initialization parameters.
to pass the parameters into public void init( ) method
developer must pass all these parameters from web.xml file.
container reads all the parameters from web.xml file
stroes into one hash kind of object called ServletConfig .
in init() method we must receive config object reads
velues from it and instantiate connection object.
if developer want to change driver parameters,then he/she
need not have to change those parameters in servlet class
instead he called modify it in web.xml file
after init() method container invokes one function on
servlet class instance called
public void service(ServletRequest req,ServletResponse res)
throws servletException,IOException
{
} client request is processed in this method
like this web creates new instance of each servlet during
first client visit to servlet.
from next request on words web container remains the same
instance and directly sends client request to service()
method.
public void destroy()
this method is used database connection want to be closed.
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What is cgi?
What are sessions in servlets?
How to make sure a servlet is loaded at the application startup?
What is the life-cycle of servlets?
Why servlet is faster than jsp?
How do you deal property files in servlet?
Why is it that we can't give relative URL's when using ServletContext.getRequestDispatcher() when we can use the same while calling ServletRequest.getRequestDispatcher()?
What is the capacity the doget can send to the server?
Explain servlet life cycle?
How can you push data from an Applet to a Servlet?
What is a web application and what is it’s directory structure?
Elucidate servlet attributes and its scope?
What is servlet and its advantages?
Why is httpservlet declared abstract?
What is cgi and what are its drawbacks?