JSP (JavaServer Pages) is a technology, which is intended for the development of dynamical HTML pages and is based on the Java language. Originally it was developed in Sun, then it was bought by an Oracle company. When creating, primarily are used HTML and Java, which is inserted in the HTML code. On the side of the server is then inserted the generated HTML file instead of Java, so it is a similar principal as in the PHP case. The extension of the files is .jsp.
The life cycle of JSP
In a moment, when the request from the client on server is sent, the web container verifies existence of Servlet to the given JSP page. In a case of its absence, Servlet creates it. If it already exists, it checks the date of both files and if the JSP site is newer, it creates new Servlet. Otherwise, for the maximal efficiency it uses the remaining Servlet. The life cycle then consists of seven stages:
Translation of JSP
Compilation of JSP
Loading the appropriate Servlet class – classloading
Preparation of Servlet class – instantiation
Initialization – jsplnit()
Processing of the request – jspService()
Destroy object – jspDestroy()
Advantages of using JSP
Output is standard HTML. JSP page output is standard HTML and thanks to that it is compact and universally readable in any browser.
Support of Java, it is based on HTML.
Simple language.
Supports standard tools for the web development.
Simple combinability with static templates. JSP pages are easily combined with static templates including fragments of HTML or XML with a code, which generates dynamical content.
Simple actualization. JSP pages are dynamically compiled to Servlets, so the authors of the page can easily actualize the presentation code. JSP pages can be also precompiled in a case of need.
Complete administration of JavaBeans components. JSP tags, for initiating the JavaBeans components, these components fully manage, by which they outweigh the author of the pages of the complexity of application logic.
Customized libraries. Developers can offer customized JSP libraries of tags, to which authors of pages can access with the help of syntax similar to the XML.
Simple change of logic. Developers can change the logic on the level of components without editing of individual pages, which use this logic.
Disadvantages of using JSP
The output is in HTML. Regarding to the fact, that the output is in HTML, it is not as rich in functionalities.
Difficult search for mistakes. Due to the JSP pages being translated to the Servlets and compiled, it is tough to search and correct mistakes in JSP pages.
Speed. During the first execution, JSP requires more time, because they have to be compiled on server.
Database connectivity. Database connectivity is not as easy, as it could be. Most of the suppliers of Servlet engines does not support natively shared connections.
The syntax shortcomings.