JSP page implicit object

JSP page implicit object is an instance of java.lang.Object. As we discussed earlier JSP is translated into servlet by web container. JSP page object refers to the instance of this servlet. It acts as a synonym for this object.

As it represents the servlet, it must be cast to HttpServlet. It can also be used directly on the JSP page instead of the page object.

Example:

welcome.jsp

<html>
    <head>
        <title>page implicit object example</title>
    </head>
    <body> 
        <%	
          out.print("This is a page implicit object example.");
          out.print("Name of the auto generated servlet: " 
                                              + this.getServletName()); 
        %>
    </body>
</html>

 

web.xml

<web-app>
 
  <welcome-file-list>
          <welcome-file>welcome.jsp</welcome-file>
  </welcome-file-list>	
 
</web-app>