Sometimes it is necessary to provide initial configuration information for Servlets. Configuration information for a Servlet may consist of a string or a set of string values included in the Servlet's web.xml declaration.
This functionality allows a Servlet to have initial parameters specified outside of the compiled code and changed without needing to recompile the Servlet. Each servlet has an object associated with it called the ServletConfig. This object is created by the container and implements the javax.servlet.ServletConfig interface. It is the ServletConfig that contains the initialization parameters. A reference to this object can be retrieved by calling the getServletConfig() method.
Servlet containers use ServletConfig
objects to pass initialization and context information to servlets. The initialization information generally consists of a series of initialization parameters (init parameters) and a ServletContext
object, which provides information about the server environment. A servlet can implement ServletConfig
to allow easy access to init parameters and context information, as GenericServlet
does.
Source Code of TestServ.java
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.