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
Hello, My project requirement is like I need to create a web page using MVC pattern. I hava a bean class, jsp page, servlet, service and dao. My jsp has two fields. One is dropdown list. The option values has to get populated from the database table. The other one is a text box and its value has to come from database table. As of now I have defined the fields in bean class, got the values from database using arraylists in dao class and I called this from service class. Can anyone please tell me the workflow of how the servlet will get this arraylist and populate the arraylist values as dropdown options in jsp page? Also I would like to know the role of bean class in MVC pattern? Thanks in advance!
Explain the custom jsp tags and the beans.
What is the use of request dispatcher interface?
What is the requirement of servlet config and servlet context implemented and how are they implemented?
What do you mean by servlet context?
What is the difference between 2 types of servlets?
What is the process for chaining servlet?
What is difference between get and post method?
What are the life cycle methods of the servlet?
How printwriter is different from servletoutputstream?
Why is http protocol called as a stateless protocol?
If my browser does not support cookie, and my server sends a cookie instance what will happen?
How forward () method is different from send redirect () method?
Explain url encoding?
Explain the difference between servlet and cgi?