Monday, January 24, 2011

JSP lifecycle

JSP pages are basically the extension of servlet at a higher level. JSP enables the developers to create dynamic webpages and use java language to build html pages. When JSPs are compiled, they are actually compiled to be servlets. This is done by JSP engine. The servlet that is compiled for a particular JSP is used to service all the incoming requests from the page and generate responses.
javax.servlet.jsp package uses two interfaces for this purpose, namely
  • JSPPage
  • HttpJspPage
The above mentioned interfaces have three methods to control the life cycle of the JSP page. These are:
  • jspInit()
  • jspDestroy()
  • _jspService(HttpServletRequest request,HttpServletResponse response)
      

These methods are already present in the compiled servlet of the JSP. You can define jspInit()(to initialize) and jspDestroy()(to destroy) method, but the _jspService(HttpServletRequest request,HttpServletResponse response)(for handling requests and generating responses) method is automatically generated by the JSP engine.

Thursday, January 20, 2011

What is JavaServer Pages?Its developmental phases

JSP (JavaServer Pages) is Sun Microsystem's solution to develop dynamic web pages. JSP technology has the advantage of server side scripting which imposes less load on the client. Server side scripting makes it ideal for creating web pages that are driven by databases.
JSP lets you to insert java code with in the JSP page making it easy to develop and maintain. JSP page is loaded to the web server only when it is called for the first time, after that it is not needed to load it again and again to the server's memory at every request, which make the response fast.
Pages written in JSP are not dependent on the platform just like JAVA that follows “Write Once, Run Everywhere”.
First of you will need to install a web server where you can run and test your JSPs. Following are some server names that can be used for this purpose.
JSP Development
JSP has many developmental phases. Developer's community has seen many releases of JSP from JSP 1.0 to JSP 1.2 to JSP 2.0. these releases had new features and old bugs were fixed to improve the functionality of JSP pages.
JSP 1.x
Many releases of JSP 1.x were released. JSP 1.0, JSP 1.1,and JSP 1.2 . JSP 1.2 contained some new features and bug fixes from the previous versions. The most important enhancements are given below.
  • JSP 1.2 was based on Servlet 2.3 and Java 2.
  • The include action was used without flushing.
  • The XML syntax for a JSP page was finalized.
  • A new type of page validator was added.
  • New options for tag library distribution and deployment have been added.
  • The tag handler lifecycle has been clarified.
For more information, please visit this.

JSP 2.0
This version of the JSP specification includes new features which are meant to improve programmer's productivity and usability. These features include
JSP 2.0 had a problem in the tag library about how the JSP version information was represented.
JSP 2.1
JSP 2.1 leverages the Servlet 2.5 specification for its web semantics.
This version has new expression language (EL ) syntax that allows deferred evaluation of expressions.
It supports resource injection through annotations.
For more differences between JSP 2.0 and JSP 2.1 visit this.