What is the difference between servlet config and servlet
context.

Answer Posted / amit singh(mca ,niet)

servlet config is a configuration object used by the
servlet container to pass information to a servlet to a
durimg intialization ,before calling the service method to
a request it calls the init(servlet config) to intialize
the servlet ,at this time it loads all the parameter the
servlet neede, if you need that some parameter only has
relation with the servlet not the whole webapplication you
should to go with servlerconfig ,we use it in
deploymentdescriptor,if you want those information those
you want to use for whole application in which many servlet
so use servletcontext
caution is that :-try to not use servlet context in web
application becaz they are not thread safe
and in deploy ment descritor you use like that:-
<web-app>
<context-param>
<param-name>............<param-name>
<param-value>..........<param-value>
</contextparam>
<servlet>
<servlet-name>.............</servlet-name>
<servlet-class>..........</servlet-class>
<init-param>
<param-value>..........</parm-value>
<param-value>........</param-value>
</init-param>
</servle..
</web-ap...
i think u got the right answer ,and best of luck
AMIT SINGH (MCA,NIET,greaternoida) and my email id
amitsing2008@gmail.com for those want more answer related
to java

Is This Answer Correct ?    57 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which http method is said to be non-idempotent and idempotent?

795


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

773


What is dispatcher servlet?

760


What's the difference between authentication and authorization?

748


What do you mean by a filter and how does it work?

694






What is the difference between get and post methods?

760


What is the procedure for initializing a servlet?

728


How many servlet objects are created?

745


How can you start a jta transaction from a servlet deployed on jboss?

842


What's the servlet interface?

792


What is the difference between the getrequestdispatcher(string path) method of javax.servlet.servletrequest interface and javax.servlet.servletcontext interface?

735


What is called Scriptlet?

799


What are the types of protocols supported by httpservlet ?

902


What do you mean by scope object and what are its types?

755


What if we pass negative value in load-on-startup?

1003