servlet it is associated with.
Key Methods:
getServletName(): Returns the name of the servlet.
getInitParameter(String name): Retrieves the value of a specific initialization parameter for the
servlet.
getServletContext(): Returns the ServletContext object for the web application.
Copy
public class ConfigExampleServlet extends HttpServlet {
private String initParam;
public void init(ServletConfig config) throws ServletException {
[Link](config);
initParam = [Link]("initParam");
}
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
[Link]().println("Init Param: " + initParam);
}
}
xml configuration
Copy
ConfigExampleServlet
[Link]
initParam
This is an init parameter
ConfigExampleServlet
/configExample