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 httpsession object is used to view and manipulate information about a session?

736


Which java application server is the best?

554


What is string tokenizer?

632


Can filter be used as request or response?

546


What must be implemented by all servlets?

579






What is a web application and what is it’s directory structure?

588


What is servlet and its advantages?

528


How do you invoke a Servlet? What is the difference between doPost method and doGet method?

650


What is cgi?

602


Write a simple servlet program to print the contents of html.

553


In the servlets, we are having a web page that is invoking servlets ,username and password? which is checks in database? Suppose the second page also if we want to verify

588


Can servlet have a constructor ?

599


Can you send an authentication error from a servlet?

528


Explain servlet events?

566


Which are the different ways you can communicate between servlets?

532