What is the difference between servlet config and servlet
context.

Answer Posted / vkrishna88

ServletConfig:
1)An object of ServletConfig exists one per Servlet...
2)An object of ServletConfig will be created when
init(ServletConfig)method is executed...
3)The data to a servlet which related to ServletConfig
object must be written in <init-param>....</init-param> with
in <servlet>…</servlet> of web.xml....
4)An object of ServletConfig will exists as long as a
specific Servlet is executing.

ServletContext:
1)An object of ServletContext exists one per web application....
2)An object of ServletContext will be created when we deploy
the web application in servlet container or servlet
execution environment......
3)The common data or global data related to ServletContext
must be written under <context-param>…</context-param> with
in <web-app>....</web-app> and outside of
<servlet>...</servlet> of web.xml....
4)An object of ServletContext will exists until the entire
web application completed its execution.....

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What if you need to span your transaction across multiple servlet invocations?

574


How to upload a file to the server using servlet?

531


Why session tracking is needed?

580


What's the architecture of a servlet package?

556


Explain Action Servlet?

621






What is the major difference between context parameter and context attribute?

591


Explain the servlet filter.

538


How we can call a jsp from the servlet?

529


Describe some assignments that are executed by servlet container?

579


What do you mean by interservlet communication?

578


How does java thread pool work?

542


What is servlet in simple terms?

561


how the HTML data stored in web server?

1952


How can a servlet be used to generate plain text instead of html?

541


What is the GenericServlet class?

595