What is the difference between servlet config and servlet
context.

Answer Posted / venkat

1)The "ServletConfig" , Config stands for configuration.it
is about deployment values you have configred for the
servlet.mostly those values which your servlet might want
to access that you dont want to hard-code,like may be a d/b
name.
{one of the reasons you dont want to hard-code"you have to
recompile the entire servlet if you wish to change a single
value},
It is Unique for each servlet(in a layman's language,one
can treat it as local variables to a particular method).
if you wish to change the values,you can do it by modifying
DeploymentDescriptor(in other words:web.xml)

2)ServletContext(they might have named it AppContext
instead of ServletContext):- you have only one
ServletContext for an entire application{NOTE:-.only if the
application is not distributed, in other scenario,you have
one for each JVM}
you can think it as a bulletin-board, where you can
put up messages (called attributes) that other parts of the
application can access.{in a layman's language one can
treat it as a static values}

you can use it to get server info, including the name and
version of the
Container, and the version of the API that’s supported.

Is This Answer Correct ?    16 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the element?

759


Is tomcat a servlet container?

758


Can you use javascript in servlets?

776


What is the life cycle of a servlet?

1040


What is session?

786


Difference between httpservlet and generic servlets?

795


Why do we need a constructor in a servlet if we use the init method?

716


When servlet object is created?

786


Explain mvc pattern.

747


What is a servlet engine?

716


What is the difference between Servlets and Applets?

726


What is difference between GenericServlet and HttpServlet?

726


How can you push data from an Applet to a Servlet?

808


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!

1982


What is the difference in between the httpservlet and generic servlet?

818