Servlet Context example
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
public class Servletcontext extends HttpServlet {
public void doGet(HttpServletRequest req,HttpServletResponse res)
throws IOException,ServletException
{
PrintWriter pw=res.getWriter();
res.setContentType("text/html");
ServletContext ctx=getServletConfig().getServletContext();
pw.println("name:'"+ctx.getInitParameter("name")+"'");
pw.println("name:'"+ctx.getInitParameter("password")+"'");
}
}
<context-param> <param-name>name</param-name> <param-value>NAVJYOTI</param-value> </context-param> <context-param> <param-name>password</param-name> <param-value>NAVEENJYOTI7</param-value> </context-param>