JSP is designed for the less java-capable web developers to be used as a web server side programming language.

However, I would argue that knowing java well still makes your jsp programming life much easier. Since we have already have Servlet in our programming tool box, why do we need JSP? Well, JSP makes programming easier compared to Servlet especially for the developers coming from the front-end side. The differences between JSP and Servlet can be summarized as follows:

  • JSP is java being contained in HTML file
  • Servlet is HTML being contained in Java file

To further illustrate this, let’s have a look at the following simple JSP example code:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>example code of HTML</title>
</head>
<body>
	<%
	out.println("<h1>Hello world</h1>");
	%>
</body>
</html>
#=> prints 'Hello world'.

Although JSP and Servlet are different on the superficial side, they are the same thing inside the web server engine. When you put the above example code inside a file called example.jsp and put the file inside the root folder of webapps in the tomcat home directory, visiting the example.jsp file using a browser will produce a file called example_jsp.java and a file called example_jsp.class under the work folder of the tomcat home directory.The two auto-produced files reveals the fact that JSP and Servlet are both java classes in the final stage of the web server processing.

More infomation can be obtained from the same book :book: Professional Java for Web Applications by Nicholas S. Williams.