Sunday, December 21, 2014

JSP implicit objects

Every JSP file has 9 implicit object which you can use directly without being declared.
Implicit objects are the objects that are available for the use in JSP documents without being declared first. These objects are parsed by the JSP engine and inserted into the generated Servlet.
JSP implicit objects are as below:

Implicit object Scope comment
request Request request
response Page response
pageContext Page page environment
session Session session
application Application same as ServeletContext
out Page Writing to the outputstream
config Page same as ServeletConfig
page Page this pasge's Servlet
exception Page exception created on this page

Note: If you have your own object defined with same name as the implicit Object, then Implicit objects take precedence over your object. So, avoid to use implicit object name as your own object. 


Saturday, December 20, 2014

JSP Life cycle

Any Java server Page or JSP have below given life cycle phase

  • Pre-translated: Before the JSP file has been translated and compiled into the Servlet. In this step, any JSP file first converted into java file(it parse all jsp content and generate Servlet file)
  • Translated: The JSP file has been translated and compiled as a Servlet. In this phase Servet created in previous step has compiles and converted into class file)
  • Initialized: Prior to handling the requests in the service method the container calls the jspInit() to initialize the Servlet. It is called only once per Servlet instance.
  • Service: Services the client requests. Container calls this method for each request.
  • Destroy: The Servlet instance is out of service. The container calls the jspDestroy() method.