Introduction to JSP

In the previous tutorial, we have covered Servlet and advance servlet topics such as various techniques to manage the session. In this tutorial, we will learn what is JSP and why we use JSP. Basically, it is an introductory part of JSP. We will learn all the topics related to JSP tutorial. But first, you need the basic understanding of JSP

What is JSP?

JSP stands for Java Server Pages. It is a server-side technology. It is used to create a dynamic web application. The key part of the Java 2 Enterprise Edition(J2EE) platform is the JavaServer Pages(JSP) technology. To simplify dealing with presentation and dynamic data on web pages is the goal of JSP technology.
introduction to jsp
JSP Introduction
The JSP technology is based on the servlet technology, in fact, all the JSP pages are eventually compiled into a servlet code. However, it is found that writing a JSP page is far less involved compared to writing a servlet code. This is written by those who don't have java experience. A JSP page is a markup document which can be either in JSP syntax or in Extensible Markup Language(XML ) format.


Drawbacks of Servlet Technology:

1. Whenever we are developing the servlet must and should we have to configure inside the web.xml file.

2. Whenever we are modifying the servlet must and should we need to stop the server and we need to compile the servlet and restart the server.

3. Servlet is allowed by the java code but not text and HTML code.

4. Whenever we are using the servlet presenting the data is very slow.

Read more about servlet:  What is Servlet in Java?

Difference between servlets and JSP:

The difference between servlet and JSP is given below:

1. JSP is an extension of a servlet. It contains all feature of servlets and extra it contains an implicit object, tags, custom action, etc.

2. Whenever we are modifying in servlet we have to recompile, redeploy and restart the server. If we do any modification in JSP just refresh button is enough to reflect the changes.

3. Servlets require more java knowledge, while JSP requires less java knowledge because JSP is tag based.

4. In the MVC(Model Control View) the servlets are acting as a controller part and JSP is acting as a Model part.

5. In servlets, we are mixing both business logic as well as presentation logic, But in JSP we can separate both presentation and business logic.

6. Servlets are good at to write Business logic while JSP is good at to write presentation logic.

7. To access the servlets web.xml file are mandatory, But to access the JSP file the web.xml file is optional.

8. Performance wise servlets are better than JSP.

9. Life Cycle methods of servlets are init(),service() and destroy(),while the life cycle methods of JSP are _jspinit(), _jspservice(), _jspdestroy().

Advantages of JSP Technology:

1. Whenever we are developing the one JSP page we no need to configure inside the web.xml file.

2. Presenting the data is very fast compared to a servlet.

3. Whenever we are modifying the JSP we no need to start the server, stop the server and restart the server.

4. The JSP pages are allowed by the HTML code and textual data and java code also.

Rule of JSP page:

1. Whenever we are developing the JSP page must and should we need to save extension is .jsp.

2. After developing the JSP page must and should we need to place inside the application scope(under root folder).


Introduction to JSP Introduction to JSP Reviewed by Prashant Srivastava on November 08, 2018 Rating: 5

No comments:

Powered by Blogger.