Saturday, May 2, 2015

Servlet Config Interface


javax.servlet.ServletConfig is used to pass configuration information to Servlet. Every servlet
has it’s own ServletConfig object and servlet container is responsible for instantiating this object.
We can provide servlet init parameters in web.xml file or through use of WebInitParam annotation. We can use getServletConfig() method to get the ServletConfig object of the servlet.
The important methods of ServletConfig interface are:
• public abstract ServletContext getServletContext() – This method returns the ServletContext
object for the servlet. We will look into ServletContext interface in next section.
• public abstract Enumeration getInitParameterNames() – This method returns the
Enumeration of name of init parameters defined for the servlet. If there are no init parameters
defined, this method returns empty enumeration.
• public abstract String getInitParameter(String paramString) – This method can be used to
get the specific init parameter value by name. If parameter is not present with the name, it returns
null.

No comments:

Post a Comment

Contact Form

Name

Email *

Message *