Introduction - To - JavaServerPage (JSP) - JSP - Processing
Introduction - To - JavaServerPage (JSP) - JSP - Processing
Introduction to JSP
• JSP is a server side technology. It is used for creating dynamic web
applications, using java as programming language.
• The JSP pages are easier to maintain than Servlet because we can
separate designing( Presentation Logic) and development( Business
Logic).
• JSP pages are opposite of Servlets as a servlet adds HTML code inside
Java code, while JSP adds Java code inside HTML using JSP tags.
• Easy to maintain
JSP can be easily managed because we can easily separate our
business logic with presentation logic.
In Servlet technology, we mix our business logic with the
presentation logic.
PATH=“C:\Program Files\Java\jdk1.8.0_191\bin;.;”
JAVA_HOME=“C:\Program Files\Java\jdk1.8.0_191”.
In Linux( ubuntu )
var/lib/tomcat/webapps/foldername/filename.jsp
localhost:8080/foldername/filename.jsp
Example:
“sample.jsp”
<html>
<head>
<title>Sample JSP</title>
</head>
<body>
<% out.println("Welcome to JSP"); %>
</body>
</html>
Output:
Example: To display Current System Date and Time
“printdate.jsp”
<%@page import="java.util.Date"%>
<html>
<body>
<%
Date d=new Date();
out.println("Today Date is :"+d);
%>
</body>
</html>
Output:
JSP Processing
• Any Web server needs a container to run any web component
(or) to provide interface to run web components.
S
1.Request E 3.Generate
R .java file Sample.java
CLIENT
V
6.Response
E 4.Converted into .class file
R
5.Execute request
& Sample.class
Generate response