32. What is the difference between ServletContext and ServletConfig

public interface ServletContext

  • Defines a set of methods that a servlet uses to communicate with its servlet container, for example, to get the MIME type of a file, dispatch requests, or write to a log file.
  • There is one context per “web application” per Java Virtual Machine.
  • The ServletContext object is contained within the ServletConfig object, which the Web server provides the servlet when the servlet is initialized.

public interface ServletConfig

  • A servlet configuration object used by a servlet container used to pass information to a servlet during initialization.
  • This object defines how a servlet is to be configured is passed to a servlet in its init method.
  • Most servlet containers provide a way to configure a servlet at run-time (usually through flat file) and set up its initial parameters.
  • The container, in turn, passes these parameters to the servlet via the ServetConfig.
Advertisements

9 Responses

  1. R u sure about these Difference .Can u give example of – a servlet configuration object used by a servlet container used to pass information to a servlet during initialization.

  2. can any 1 explain about the process of creating a servlet object and how the initilaization parameters and al de stuff will be provided to de servletobject by the container?

  3. Servlet Context :
    In servlet programming, the servlet context is the
    environment where the servlet runs. The servlet container
    creates a ServletContext object that you can use to access
    information about the servlet’s environment.

    ServletConfig:
    A servlet configuration object used by a servlet container
    used to pass information to a servlet during initialization.

  4. http://www.onlineinfomat.com information on servletconfig and servletcontext is very useful. thank you

    http://www.onlineinfomat.com

    Onlinejava training here

  5. resource is good.all the best.

  6. HI we are provinding materials for consultants

  7. Nice points you have covered on ServletContext and ServletConfig. Here you can find some more points on ServletConfig and ServletContext.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: