How to override the jspInit() method?

If you implement a jspInit() method, the container calls this method at the beginning of the pages’s life as servlet. By this time this method runs there is a ServletConfig and ServletContext available to the servlet. That means you can call the getServletConfig() and getServletContext() withen the jspInit() method.
Overriding jspInit() method:
<%!
Public void jspInit(){
ServletConfig config=getServletConfig();
String email=config.getInitParameter(“email”);
ServletContext context=getServletContext();
contex.setAttribute(“email”,email);
}
%>

No comments:

Post a Comment