Professional Documents
Culture Documents
Dynamic contents
– Contents is dynamically generated based on
conditions
Conditions could be
- User identity
- Time of the day
- User entered values through forms etc..
What is JSP Page?
A text-based document capable of returning both
static and dynamic content to a client browser
-- Static content and dynamic content can be
intermixed
--Static content
– HTML, XML, Text
-- Dynamic content
– Java code
– Displaying properties of Java Beans
– Invoking business logic defined in Custom tags
A Simple JSP Page
(Blue: static, Red: Dynamic contents)
<html>
<body>
Hello World!
<br>
Current time is <%= new
java.util.Date() %>
</body>
</html>
Comparison Servlets And JSP
JSP Benefits
--Content and display logic are separated
-- Simplify web application development with JSP,
JavaBeans and custom tags
--Translation phase
--Compile phase
--Execution phase
JSP COMPONENTS
Directives : JSP directive affects the overall
structure of the servlet that results from the JSP page.
Expressions : Of the form <%= expression %>,
which are evaluated and inserted into the servlet’s output
Scriptlets : Of the form <% code %>, which are
inserted into the servlet’s _jspService method (called by
service)
Declarations : Of the form <%! code %>, which
are inserted into the body of the servlet class, outside of
any existing methods
JSP Directives
General Syntax :
--include Directive :
<%@ include file=“header.jsp” %>
--taglib Directive :
<%@ taglib uri="..." prefix="..." %>