0% found this document useful (0 votes)
6 views1 page

Servlet Configuration and Methods Guide

The document describes a Java servlet class named ConfigExampleServlet that retrieves and displays an initialization parameter. It includes key methods such as getServletName(), getInitParameter(), and getServletContext(). Additionally, it provides an XML configuration example for the servlet and its initialization parameter.

Uploaded by

myselfsachin745
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Servlet Configuration and Methods Guide

The document describes a Java servlet class named ConfigExampleServlet that retrieves and displays an initialization parameter. It includes key methods such as getServletName(), getInitParameter(), and getServletContext(). Additionally, it provides an XML configuration example for the servlet and its initialization parameter.

Uploaded by

myselfsachin745
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

You might also like