Monday, 10 November 2014

Implicit Objects in JSP

The objects created by the web container and available on all jsp pages are known as implicit objects.
There is no need to declare them explicitly for the Developer.They are pre-defined variables.

One thing to note-
These objects can be used inside scriplets that goes to _jspService() method but they can not be used in jsp declaration
because it will go at the class level.
I am attaching the generated servlet code of a simple jsp that will help
to understand how they are created by the container and available implicitly.

JSP page
....
<body>
Hiii JSP Learner
</body>
....
Generated code for this jsp
There are total 9 implicit objects available.

    Object                                Type
  1. out JspWriter
  2. request HttpServletRequest
  3. response                         HttpServletResponse
  4. config ServletConfig
  5. application ServletContext
  6. session HttpSession
  7. pageContext PageContext
  8. page Object
  9. exception Throwable