SlideShare a Scribd company logo
JAVA SERVER PAGE DIRECTIVES
A. D. PATEL INSTITUTE OF TECHNOLOGY
AJ(2160707) : A.Y. 2018-19
GUIDED BY:
PROF. NAYAN MALI
(DEPT OF IT, ADIT)
PREPARED BY:
KUNAL KATHE
E.R.NO.:160010116023
DHRUV SHAH
E.R.NO.:160010116053
CHINTAN SUDANI
E.R.NO.:160010116056
DEPARTMENT OF INFORMATION TECHNOLOGY
A D PATEL INSTITUTE OF TECHNOLOGY (ADIT)
NEW VALLABH VIDYANAGAR, ANAND, GUJARAT
2
Introduction To JSP:
• JSP technology has facilitated the segregation of the work of a Web designer and a Web
developer.
• A Web designer can design and formulate the layout for the Web page by using HTML.
• On the other hand, a Web developer working independently can use java code and other
JSP specific tags to code the business logic.
• The simultaneous construction of the static and dynamic content facilitates development of
quality applications with increased productivity.
• A JSP page , after compilation , generates a servlet and therefore incorporates all servlet
functionalities.
3
• Servlets and JSP thus share common features, such as platform independence , creation of
database-driven Web applications , and server side programming capabilities.
• Servlets tie up files (an HTML file for the static content and a Java file for the dynamic
contents) to independently handle the static presentation logic and the dynamic business
logic.
• Due to this , a change made to any file requires recompilation of the servlet.
• JSP on the other hand allows Java to be embedded directly into an HTML page by using tags.
• The HTML content and the Java content can also be placed in separate files.
• Any changes made to HTML content is automatically compiled and loaded onto the servlet
4
JSP Directives:
• JSP directives provide directions and instructions to the container, telling it how
to handle certain aspects of JSP processing.
• A JSP directive affects the overall structure of the servlet class.
• It usually has the following form:
<%@ directive attribute="value" %>
• The blanks between the @ symbol and the directive name, and between the last attribute
and the closing %>, are optional.
Directive Description
<%@ page ... %> Defines page-dependent attributes, such as scripting language, error
page, and buffering requirements.
<%@ include ... %> Includes a file during the translation phase.
<%@ taglib ... %> Declares a tag library, containing custom actions, used in the page
5
Page directives:
• The page directive is used to provide instructions to the container that pertain to
the current JSP page. You may code page directives anywhere in your JSP page. By
convention, page directives are coded at the top of the JSP page.
• Following is the basic syntax of page directive:
<%@ page attribute="value" %>
• You can write XML equivalent of the above syntax as follows:
<jsp:directive.page attribute="value" />
6
Following is the list of attributes associated with page directive:
Attribute Purpose
buffer Specifies a buffering model for the output stream.
autoFlush Controls the behavior of the servlet output buffer.
contentType Defines the character encoding scheme.
errorPage Defines the URL of another JSP that reports on Java unchecked
runtime exceptions.
isErrorPage Indicates if this JSP page is a URL specified by another JSP
page's errorPage attribute.
extends Specifies a superclass that the generated servlet must extend
import Specifies a list of packages or classes for use in the JSP as the
Java import statement does for Java classes.
info Defines a string that can be accessed with the servlet's
getServletInfo() method.
isThreadSafe Defines the threading model for the generated servlet.
language Defines the programming language used in the JSP page.
session Specifies whether or not the JSP page participates in HTTP
sessions
isELIgnored Specifies whether or not EL expression within the JSP page will
be ignored.
isScriptingEnabled Determines if scripting elements are allowed for use.
7
Include directive:
• The include directive is used to include a file during the translation phase. This
directive tells the container to merge the content of other external files with the
current JSP during the translation phase. You may code include directives
anywhere in your JSP page.
• The general usage form of this directive is as follows:
<%@ include file="relative url" >
• If you just specify a filename with no associated path, the JSP compiler assumes that
the file is in the same directory as your JSP.
• You can write XML equivalent of the above syntax as follows:
<jsp:directive.include file="relative url" />
8
taglib directive:
• The JavaServer Pages API allows you to define custom JSP tags that look like
HTML or XML tags and a tag library is a set of user-defined tags that implement
custom behavior.
• The taglib directive declares that your JSP page uses a set of custom tags,Identifies the
location of the library, and provides a means for identifying the custom tags in your JSP.
• The taglib directive follows the following syntax:
<%@ taglib uri=“http://java.sun.com/jsp/jstl/ex" prefix="prefixOfTag" >
where ex=(core | xml | function | sql)
• Where the uri attribute value resolves to a location the container understands and
the prefix attribute informs a container what bits of markup are custom actions.
9
JSP Tags:
• There are five main tags:
1. Declaration tag
2. Expression tag
3. Directive tag
4. Scriptlet tag
5. Action tag
10
Declaration tag :
• This tag allows the developer to declare variables or methods.
• Before the declaration you must have <%! And at the end of the declaration the
developer must have %>.
• Code placed in this must end in a semicolon(;)
• Declarations do not generate output, so are used with JSP expressions or scriptlets.
• Example:
<%!private int counter = 0 ;
private String getAccount (int accountNo);
%>
11
Expression tag:
• This tag allows the developer to embed any java expression and is short for
out.println().
• A semicolon (;) does not appear at the end of the code inside the tag.
• Example:
<%= new java.util.Date() %>
12
Directive tag:
• A JSP directive gives special information about the jsp page , to the JSP Engine.
• There are three main types of directives:
1. page - processing information for this page
2. Include - files to be included
3. Tag library - tag library to be used in this page
• Directives do not produce any visible output when the page is requested but change the
way the JSP engine processes the page.
• For example , you can make session data unavailable to a page by setting a page
directive (session) to false.
13
Scriptlet tag:
• Between <% and %> tags , any valid Java Code is called a Scriptlet.
• This code can access any variable or bean declared.
• Example:
• <%
String message = “Be in Peace” ;
out.println(message);
%>
14
Action tag:
• Standard Actions are tags that affect the runtime behavior of the JSP and the response
sent back to the user.
• They have to provided by the container irrespective of the usage.
• During compilation into the servlet , the container comes across the this tag and
replaces it with Java code that corresponds to the required predefined task.
• There are three main roles of the action tags:
• Enable the use of the server side Javabeans.
• Transfer control between pages
• Browser independent support for applet
15
Contd…
• Types of the Standard Action :
• <jsp:usebean>
• <jsp:setProperty>
• <jsp:getProperty>
• <jsp:param>
• <jsp:include>
• <jsp:forward>
• <jsp:plugin>
16
Examples Of JSP :
o Action Tag:
• DatePage.jsp
<html>
<body><%= new java.util.Date () %></body>
</html>
• IncludePage.jsp
<html>
<body><h4> Today’s Date is :<jsp:include page=“DatePage.jsp” flush=“true” /> </h4>
<% out.println(“<h4> The ouput of the file DatePage.jsp is shown above </h3>”); %>
</body>
</html>
17
o Taglib Directive :
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head><title>Welcome Page</title></head>
<body>
<c:out value="${'Welcome Dhruv'}" />
</body>
</html>
Output:
18
o Include Directive :
 Login.jsp
<%@include file="include/header.jsp"%>
<%
String USERNAME = (String) request.getSession().getAttribute("USERNAME");
if (USERNAME != null) {
response.sendRedirect("home.jsp");
}
%>
<h2 style="color: lightgray">
<a href="index.jsp">Home</a>
</h2>
<body>
<div class="container">
<form action="AuthenticatorServlet" method="post">
<div class="card">
<center>
<div class="card-header" style="background-color: lightblue">LOGIN
HERE</div></center>
19
<div class="card-body">
<table class="table">
<tr>
<td colspan="2" class="error">
<%
String error = (String) request.getAttribute("ERROR");
if (error != null)
out.println(error);
%>
</td>
</tr>
<tr>
<td>Username</td>
<td><input type="text" name="username" class="form-control"
placeholder="Enter username" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password"
class="form-control" placeholder="Enter password" /></td>
</tr>
20
<tr>
<td></td>
<td><input type="submit" class="btn btn-success"
class="form-control" name="button" value="Submit"></td>
</tr>
</table>
</div>
</div>
</form>
</div>
<%@include file="include/footer.jsp"%>
</body>
</html>
21
 header.jsp
<%@ page language="java" %>
<!DOCTYPE html>
<html>
<head>
<title>ADIT Login Page</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
</head>
<h1 style="background-color:blue;color:white;text-align:center;">A D Patel Institute Of Technology</h1>
 Footer.jsp
<h3 style="background-color:blue;color:white;text-align:center;">Designed &amp; &copy; Developed By
Dhruv</h3>
</body>
</html>
22

More Related Content

What's hot

ASP.NET Page Life Cycle
ASP.NET Page Life CycleASP.NET Page Life Cycle
ASP.NET Page Life Cycle
Abhishek Sur
 
Enterprise java unit-3_chapter-1-jsp
Enterprise  java unit-3_chapter-1-jspEnterprise  java unit-3_chapter-1-jsp
Enterprise java unit-3_chapter-1-jsp
sandeep54552
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
BG Java EE Course
 
Javascript
JavascriptJavascript
Javascript
mussawir20
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Jsp chapter 1
Jsp chapter 1Jsp chapter 1
Jsp chapter 1
kamal kotecha
 
Cookies & Session
Cookies & SessionCookies & Session
Java Script ppt
Java Script pptJava Script ppt
Java Script ppt
Priya Goyal
 
JDBC ppt
JDBC pptJDBC ppt
JDBC ppt
Rohit Jain
 
Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentation
Manav Prasad
 
DHTML - Events & Buttons
DHTML - Events  & ButtonsDHTML - Events  & Buttons
DHTML - Events & Buttons
Deep Patel
 
Operators in java
Operators in javaOperators in java
Operators in java
AbhishekMondal42
 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
Vikas Jagtap
 
Web controls
Web controlsWeb controls
Web controls
Sarthak Varshney
 
Literals,variables,datatype in C#
Literals,variables,datatype in C#Literals,variables,datatype in C#
Literals,variables,datatype in C#
Prasanna Kumar SM
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
Tanmoy Barman
 
Implicit object.pptx
Implicit object.pptxImplicit object.pptx
Implicit object.pptx
chakrapani tripathi
 
Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/js
Knoldus Inc.
 

What's hot (20)

ASP.NET Page Life Cycle
ASP.NET Page Life CycleASP.NET Page Life Cycle
ASP.NET Page Life Cycle
 
Enterprise java unit-3_chapter-1-jsp
Enterprise  java unit-3_chapter-1-jspEnterprise  java unit-3_chapter-1-jsp
Enterprise java unit-3_chapter-1-jsp
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Javascript
JavascriptJavascript
Javascript
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Threads in JAVA
 
Jsp chapter 1
Jsp chapter 1Jsp chapter 1
Jsp chapter 1
 
Cookies & Session
Cookies & SessionCookies & Session
Cookies & Session
 
Java Script ppt
Java Script pptJava Script ppt
Java Script ppt
 
JDBC – Java Database Connectivity
JDBC – Java Database ConnectivityJDBC – Java Database Connectivity
JDBC – Java Database Connectivity
 
Java Swing
Java SwingJava Swing
Java Swing
 
JDBC ppt
JDBC pptJDBC ppt
JDBC ppt
 
Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentation
 
DHTML - Events & Buttons
DHTML - Events  & ButtonsDHTML - Events  & Buttons
DHTML - Events & Buttons
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
 
Web controls
Web controlsWeb controls
Web controls
 
Literals,variables,datatype in C#
Literals,variables,datatype in C#Literals,variables,datatype in C#
Literals,variables,datatype in C#
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 
Implicit object.pptx
Implicit object.pptxImplicit object.pptx
Implicit object.pptx
 
Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/js
 

Similar to JSP Directives

Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
Shah Nawaz Bhurt
 
Jsp
JspJsp
SCWCD : Java server pages CHAP : 9
SCWCD : Java server pages  CHAP : 9SCWCD : Java server pages  CHAP : 9
SCWCD : Java server pages CHAP : 9
Ben Abdallah Helmi
 
Jsp
JspJsp
JSP.pptx
JSP.pptxJSP.pptx
JSP.pptx
NishaRohit6
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
Raheela Patel
 
Jsp in Servlet by Rj
Jsp in Servlet by RjJsp in Servlet by Rj
Jsp element
Jsp elementJsp element
Jsp element
kamal kotecha
 
Servlets and jsp pages best practices
Servlets and jsp pages best practicesServlets and jsp pages best practices
Servlets and jsp pages best practicesejjavies
 
Java Web Programming [4/9] : JSP Basic
Java Web Programming [4/9] : JSP BasicJava Web Programming [4/9] : JSP Basic
Java Web Programming [4/9] : JSP Basic
IMC Institute
 
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Ayes Chinmay
 
Jsp
JspJsp
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 ...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 ...Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 ...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 ...
WebStackAcademy
 
JSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESJSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGES
Yoga Raja
 
Transformation of Java Server Pages: A Modern Approach
Transformation of Java Server Pages: A Modern ApproachTransformation of Java Server Pages: A Modern Approach
Transformation of Java Server Pages: A Modern Approach
IRJET Journal
 
Spatial approximate string search Doc
Spatial approximate string search DocSpatial approximate string search Doc
Spatial approximate string search Doc
Sudha Hari Tech Solution Pvt ltd
 
Jsp and jstl
Jsp and jstlJsp and jstl
Jsp and jstl
vishal choudhary
 

Similar to JSP Directives (20)

Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Jsp
JspJsp
Jsp
 
SCWCD : Java server pages CHAP : 9
SCWCD : Java server pages  CHAP : 9SCWCD : Java server pages  CHAP : 9
SCWCD : Java server pages CHAP : 9
 
Jsp
JspJsp
Jsp
 
JSP.pptx
JSP.pptxJSP.pptx
JSP.pptx
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Jsp in Servlet by Rj
Jsp in Servlet by RjJsp in Servlet by Rj
Jsp in Servlet by Rj
 
Jsp element
Jsp elementJsp element
Jsp element
 
Servlets and jsp pages best practices
Servlets and jsp pages best practicesServlets and jsp pages best practices
Servlets and jsp pages best practices
 
Java Web Programming [4/9] : JSP Basic
Java Web Programming [4/9] : JSP BasicJava Web Programming [4/9] : JSP Basic
Java Web Programming [4/9] : JSP Basic
 
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
 
Jsp tutorial
Jsp tutorialJsp tutorial
Jsp tutorial
 
Jsp
JspJsp
Jsp
 
JSP Technology I
JSP Technology IJSP Technology I
JSP Technology I
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 ...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 ...Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 ...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 ...
 
servlets and jsp
servlets and jspservlets and jsp
servlets and jsp
 
JSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESJSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGES
 
Transformation of Java Server Pages: A Modern Approach
Transformation of Java Server Pages: A Modern ApproachTransformation of Java Server Pages: A Modern Approach
Transformation of Java Server Pages: A Modern Approach
 
Spatial approximate string search Doc
Spatial approximate string search DocSpatial approximate string search Doc
Spatial approximate string search Doc
 
Jsp and jstl
Jsp and jstlJsp and jstl
Jsp and jstl
 

More from ShahDhruv21

Semantic net in AI
Semantic net in AISemantic net in AI
Semantic net in AI
ShahDhruv21
 
Error Detection & Error Correction Codes
Error Detection & Error Correction CodesError Detection & Error Correction Codes
Error Detection & Error Correction Codes
ShahDhruv21
 
Secure Hash Algorithm (SHA)
Secure Hash Algorithm (SHA)Secure Hash Algorithm (SHA)
Secure Hash Algorithm (SHA)
ShahDhruv21
 
Data Mining in Health Care
Data Mining in Health CareData Mining in Health Care
Data Mining in Health Care
ShahDhruv21
 
Data Compression in Data mining and Business Intelligencs
Data Compression in Data mining and Business Intelligencs Data Compression in Data mining and Business Intelligencs
Data Compression in Data mining and Business Intelligencs
ShahDhruv21
 
MongoDB installation,CRUD operation & JavaScript shell
MongoDB installation,CRUD operation & JavaScript shellMongoDB installation,CRUD operation & JavaScript shell
MongoDB installation,CRUD operation & JavaScript shell
ShahDhruv21
 
2D Transformation
2D Transformation2D Transformation
2D Transformation
ShahDhruv21
 
Interpreter
InterpreterInterpreter
Interpreter
ShahDhruv21
 
Topological Sorting
Topological SortingTopological Sorting
Topological Sorting
ShahDhruv21
 
Pyramid Vector Quantization
Pyramid Vector QuantizationPyramid Vector Quantization
Pyramid Vector Quantization
ShahDhruv21
 
Event In JavaScript
Event In JavaScriptEvent In JavaScript
Event In JavaScript
ShahDhruv21
 
WaterFall Model & Spiral Mode
WaterFall Model & Spiral ModeWaterFall Model & Spiral Mode
WaterFall Model & Spiral Mode
ShahDhruv21
 

More from ShahDhruv21 (12)

Semantic net in AI
Semantic net in AISemantic net in AI
Semantic net in AI
 
Error Detection & Error Correction Codes
Error Detection & Error Correction CodesError Detection & Error Correction Codes
Error Detection & Error Correction Codes
 
Secure Hash Algorithm (SHA)
Secure Hash Algorithm (SHA)Secure Hash Algorithm (SHA)
Secure Hash Algorithm (SHA)
 
Data Mining in Health Care
Data Mining in Health CareData Mining in Health Care
Data Mining in Health Care
 
Data Compression in Data mining and Business Intelligencs
Data Compression in Data mining and Business Intelligencs Data Compression in Data mining and Business Intelligencs
Data Compression in Data mining and Business Intelligencs
 
MongoDB installation,CRUD operation & JavaScript shell
MongoDB installation,CRUD operation & JavaScript shellMongoDB installation,CRUD operation & JavaScript shell
MongoDB installation,CRUD operation & JavaScript shell
 
2D Transformation
2D Transformation2D Transformation
2D Transformation
 
Interpreter
InterpreterInterpreter
Interpreter
 
Topological Sorting
Topological SortingTopological Sorting
Topological Sorting
 
Pyramid Vector Quantization
Pyramid Vector QuantizationPyramid Vector Quantization
Pyramid Vector Quantization
 
Event In JavaScript
Event In JavaScriptEvent In JavaScript
Event In JavaScript
 
WaterFall Model & Spiral Mode
WaterFall Model & Spiral ModeWaterFall Model & Spiral Mode
WaterFall Model & Spiral Mode
 

Recently uploaded

一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
SupreethSP4
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 

Recently uploaded (20)

一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 

JSP Directives

  • 1. JAVA SERVER PAGE DIRECTIVES A. D. PATEL INSTITUTE OF TECHNOLOGY AJ(2160707) : A.Y. 2018-19 GUIDED BY: PROF. NAYAN MALI (DEPT OF IT, ADIT) PREPARED BY: KUNAL KATHE E.R.NO.:160010116023 DHRUV SHAH E.R.NO.:160010116053 CHINTAN SUDANI E.R.NO.:160010116056 DEPARTMENT OF INFORMATION TECHNOLOGY A D PATEL INSTITUTE OF TECHNOLOGY (ADIT) NEW VALLABH VIDYANAGAR, ANAND, GUJARAT
  • 2. 2 Introduction To JSP: • JSP technology has facilitated the segregation of the work of a Web designer and a Web developer. • A Web designer can design and formulate the layout for the Web page by using HTML. • On the other hand, a Web developer working independently can use java code and other JSP specific tags to code the business logic. • The simultaneous construction of the static and dynamic content facilitates development of quality applications with increased productivity. • A JSP page , after compilation , generates a servlet and therefore incorporates all servlet functionalities.
  • 3. 3 • Servlets and JSP thus share common features, such as platform independence , creation of database-driven Web applications , and server side programming capabilities. • Servlets tie up files (an HTML file for the static content and a Java file for the dynamic contents) to independently handle the static presentation logic and the dynamic business logic. • Due to this , a change made to any file requires recompilation of the servlet. • JSP on the other hand allows Java to be embedded directly into an HTML page by using tags. • The HTML content and the Java content can also be placed in separate files. • Any changes made to HTML content is automatically compiled and loaded onto the servlet
  • 4. 4 JSP Directives: • JSP directives provide directions and instructions to the container, telling it how to handle certain aspects of JSP processing. • A JSP directive affects the overall structure of the servlet class. • It usually has the following form: <%@ directive attribute="value" %> • The blanks between the @ symbol and the directive name, and between the last attribute and the closing %>, are optional. Directive Description <%@ page ... %> Defines page-dependent attributes, such as scripting language, error page, and buffering requirements. <%@ include ... %> Includes a file during the translation phase. <%@ taglib ... %> Declares a tag library, containing custom actions, used in the page
  • 5. 5 Page directives: • The page directive is used to provide instructions to the container that pertain to the current JSP page. You may code page directives anywhere in your JSP page. By convention, page directives are coded at the top of the JSP page. • Following is the basic syntax of page directive: <%@ page attribute="value" %> • You can write XML equivalent of the above syntax as follows: <jsp:directive.page attribute="value" />
  • 6. 6 Following is the list of attributes associated with page directive: Attribute Purpose buffer Specifies a buffering model for the output stream. autoFlush Controls the behavior of the servlet output buffer. contentType Defines the character encoding scheme. errorPage Defines the URL of another JSP that reports on Java unchecked runtime exceptions. isErrorPage Indicates if this JSP page is a URL specified by another JSP page's errorPage attribute. extends Specifies a superclass that the generated servlet must extend import Specifies a list of packages or classes for use in the JSP as the Java import statement does for Java classes. info Defines a string that can be accessed with the servlet's getServletInfo() method. isThreadSafe Defines the threading model for the generated servlet. language Defines the programming language used in the JSP page. session Specifies whether or not the JSP page participates in HTTP sessions isELIgnored Specifies whether or not EL expression within the JSP page will be ignored. isScriptingEnabled Determines if scripting elements are allowed for use.
  • 7. 7 Include directive: • The include directive is used to include a file during the translation phase. This directive tells the container to merge the content of other external files with the current JSP during the translation phase. You may code include directives anywhere in your JSP page. • The general usage form of this directive is as follows: <%@ include file="relative url" > • If you just specify a filename with no associated path, the JSP compiler assumes that the file is in the same directory as your JSP. • You can write XML equivalent of the above syntax as follows: <jsp:directive.include file="relative url" />
  • 8. 8 taglib directive: • The JavaServer Pages API allows you to define custom JSP tags that look like HTML or XML tags and a tag library is a set of user-defined tags that implement custom behavior. • The taglib directive declares that your JSP page uses a set of custom tags,Identifies the location of the library, and provides a means for identifying the custom tags in your JSP. • The taglib directive follows the following syntax: <%@ taglib uri=“http://java.sun.com/jsp/jstl/ex" prefix="prefixOfTag" > where ex=(core | xml | function | sql) • Where the uri attribute value resolves to a location the container understands and the prefix attribute informs a container what bits of markup are custom actions.
  • 9. 9 JSP Tags: • There are five main tags: 1. Declaration tag 2. Expression tag 3. Directive tag 4. Scriptlet tag 5. Action tag
  • 10. 10 Declaration tag : • This tag allows the developer to declare variables or methods. • Before the declaration you must have <%! And at the end of the declaration the developer must have %>. • Code placed in this must end in a semicolon(;) • Declarations do not generate output, so are used with JSP expressions or scriptlets. • Example: <%!private int counter = 0 ; private String getAccount (int accountNo); %>
  • 11. 11 Expression tag: • This tag allows the developer to embed any java expression and is short for out.println(). • A semicolon (;) does not appear at the end of the code inside the tag. • Example: <%= new java.util.Date() %>
  • 12. 12 Directive tag: • A JSP directive gives special information about the jsp page , to the JSP Engine. • There are three main types of directives: 1. page - processing information for this page 2. Include - files to be included 3. Tag library - tag library to be used in this page • Directives do not produce any visible output when the page is requested but change the way the JSP engine processes the page. • For example , you can make session data unavailable to a page by setting a page directive (session) to false.
  • 13. 13 Scriptlet tag: • Between <% and %> tags , any valid Java Code is called a Scriptlet. • This code can access any variable or bean declared. • Example: • <% String message = “Be in Peace” ; out.println(message); %>
  • 14. 14 Action tag: • Standard Actions are tags that affect the runtime behavior of the JSP and the response sent back to the user. • They have to provided by the container irrespective of the usage. • During compilation into the servlet , the container comes across the this tag and replaces it with Java code that corresponds to the required predefined task. • There are three main roles of the action tags: • Enable the use of the server side Javabeans. • Transfer control between pages • Browser independent support for applet
  • 15. 15 Contd… • Types of the Standard Action : • <jsp:usebean> • <jsp:setProperty> • <jsp:getProperty> • <jsp:param> • <jsp:include> • <jsp:forward> • <jsp:plugin>
  • 16. 16 Examples Of JSP : o Action Tag: • DatePage.jsp <html> <body><%= new java.util.Date () %></body> </html> • IncludePage.jsp <html> <body><h4> Today’s Date is :<jsp:include page=“DatePage.jsp” flush=“true” /> </h4> <% out.println(“<h4> The ouput of the file DatePage.jsp is shown above </h3>”); %> </body> </html>
  • 17. 17 o Taglib Directive : <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <!DOCTYPE html> <html> <head><title>Welcome Page</title></head> <body> <c:out value="${'Welcome Dhruv'}" /> </body> </html> Output:
  • 18. 18 o Include Directive :  Login.jsp <%@include file="include/header.jsp"%> <% String USERNAME = (String) request.getSession().getAttribute("USERNAME"); if (USERNAME != null) { response.sendRedirect("home.jsp"); } %> <h2 style="color: lightgray"> <a href="index.jsp">Home</a> </h2> <body> <div class="container"> <form action="AuthenticatorServlet" method="post"> <div class="card"> <center> <div class="card-header" style="background-color: lightblue">LOGIN HERE</div></center>
  • 19. 19 <div class="card-body"> <table class="table"> <tr> <td colspan="2" class="error"> <% String error = (String) request.getAttribute("ERROR"); if (error != null) out.println(error); %> </td> </tr> <tr> <td>Username</td> <td><input type="text" name="username" class="form-control" placeholder="Enter username" /></td> </tr> <tr> <td>Password</td> <td><input type="password" name="password" class="form-control" placeholder="Enter password" /></td> </tr>
  • 20. 20 <tr> <td></td> <td><input type="submit" class="btn btn-success" class="form-control" name="button" value="Submit"></td> </tr> </table> </div> </div> </form> </div> <%@include file="include/footer.jsp"%> </body> </html>
  • 21. 21  header.jsp <%@ page language="java" %> <!DOCTYPE html> <html> <head> <title>ADIT Login Page</title> <link rel="stylesheet" href="css/bootstrap.min.css" /> </head> <h1 style="background-color:blue;color:white;text-align:center;">A D Patel Institute Of Technology</h1>  Footer.jsp <h3 style="background-color:blue;color:white;text-align:center;">Designed &amp; &copy; Developed By Dhruv</h3> </body> </html>
  • 22. 22