SlideShare a Scribd company logo
JSP Directives , Implicit
Objects and Actions
JSP DIRECTIVES
• jsp directives are messages that tells the web container how to translate a JSP page
into the corresponding servlet.
• There are three types of directives:
1. page directive
2. include directive
3. taglib directive
• Syntax: <%@ directive attribute="value" %>
JSP page directive
• The page directive defines attributes that apply to an entire JSP page.
Syntax : <%@ page attribute="value" %>
• Attributes of JSP page directive
o import
o contentType
o extends
o info
o buffer
o language
o session
o errorPage
o isErrorPage
1) import
The import attribute is used to import class,interface or all the members of a package.It
is similar to import keyword in java class or interface
Example of import attribute
<html>
<body>
<%@ page import="java.util.Date" %>
Today is: <%= new Date() %>
</body>
</html>
2) contentType
• The contentType attribute defines the MIME(Multipurpose Internet Mail Extension) type
of the HTTP response.The default value is "text/html;charset=ISO-8859-1".
<html>
<body>
<%@ page contentType=application/msword %>
Today is: <%= new java.util.Date() %>
</body>
</html>
3)info
• This attribute simply sets the information of the JSP page which is retrieved later by
using getServletInfo() method of Servlet interface
<html>
<body>
<%@ page info="current Date will displayed" %>
Today is: <%= new java.util.Date() %>
</body>
4) errorPage
• The errorPage attribute is used to define the error page, if exception occurs in the
current page, it will be redirected to the error page.
<html>
<body>
<%@ page errorPage="myerrorpage.jsp" %>
<%= 100/0 %>
</body>
</html>
isErrorPage
• The isErrorPage attribute is used to declare that the current page is the error page.
• Note: The exception object can only be used in the error page.
<html>
<body>
<%@ page isErrorPage="true" %>
Sorry an exception occured!<br/>
The exception is: <%= exception %>
</body>
</html>
JSP Include Directive
• The include directive is used to include the contents of any resource it may be jsp file,
html file or text file. The include directive includes the original content of the included
resource at page translation time
Advantage of Include directive
• Code Reusability
<%@ include file="resourceName" %>
JSP Include Directive…
<html>
<body>
<%@ include file="header.html" %>
Today is: <%= java.util.Calendar.getInstance().getTime() %>
</body>
</html>
JSP Implicit Objects
• There are 9 jsp implicit objects. These objects are created by the web container that
are available to all the jsp pages
• Out
• Request
• Response
• Session
• Exception
• Config
• Appication
• Page
• PageContext
JSP request implicit object
• The JSP request is an implicit object of type HttpServletRequest i.e. created for each
jsp request by the web container. It can be used to get request information such as
parameter
index.html
<form action="welcome.jsp">
<input type="text" name="uname">
<input type="submit" value="go"><br/>
</form>
welcome.jsp
<%
String name=request.getParameter("uname");
out.print("welcome "+name);
%>
JSP response implicit object
• In JSP, response is an implicit object of type HttpServletResponse. The instance of
HttpServletResponse is created by the web container for each jsp request.
index.html
<form action="welcome.jsp">
<input type="text" name="uname">
<input type="submit" value="go"><br/>
</form>
welcome.jsp
<%
response.sendRedirect("http://www.google.com");
%>
session implicit object
• In JSP, session is an implicit object of type HttpSession.The Java developer can use this
object to set,get or remove attribute or to get session information.
index.html
<html>
<body>
<form action="welcome.jsp">
<input type="text" name="uname">
<input type="submit" value="go"><br/>
</form>
</body>
</html>
welcome.jsp
<html>
<body>
<%
String name=request.getParameter("uname");
out.print("Welcome "+name);
session.setAttribute("user",name);
<a href="second.jsp">second jsp page</a>
%>
</body>
</html>
second.jsp
<html>
<body>
<%
String name=(String)session.getAttribute("user");
out.print("Hello "+name);
%>
</body>
</html>
exception implicit object
• In JSP, exception is an implicit object of type java.lang.Throwable class. This object can
be used to print the exception. But it can only be used in error pages.It is better to
learn it after page
error.jsp
<%@ page isErrorPage="true" %>
<html>
<body>
Sorry following exception occured:<%= exception %>
</body>
</html>
ACTIONS
• There are many JSP action tags or elements. Each JSP action tag is used to perform
some specific tasks.
• The action tags are used to control the flow between pages and to use Java Bean. The
Jsp action tags are given below.
JSP Action Tags Description
jsp:forward forwards the request and response to
another resource.
jsp:include includes another resource.
jsp:useBean creates or locates bean object.
jsp:setProperty sets the value of property in bean
object.
jsp:getProperty prints the value of property of the bean.
jsp:plugin embeds another components such as
applet.
jsp:param sets the parameter value. It is used in
forward and include mostly.
forward action tag
• The jsp:forward action tag is used to forward the request to another resource it may be
jsp, html or another resource.
Syntax of jsp:forward action tag without parameter
<jsp:forward page="relativeURL | <%= expression %>" />
Syntax of jsp:forward action tag with parameter
<jsp:forward page="relativeURL | <%= expression %>">
<jsp:param name="parametername" value="parametervalue | <%=expression%>" />
</jsp:forward>
Example of jsp:forward action tag without parameter
index.jsp
<html>
<body>
<h2>This is first page</h2>
<jsp:forward page="printdate.jsp" />
</body>
</html>
printdate.jsp
<html>
<body>
<% out.print(“Anurag University”)%>
</body>
</html>
Example of jsp:forward action tag with parameter
index.jsp
<html>
<body>
<h2>this is index page</h2>
<jsp:forward page=“welcome.jsp" >
<jsp:param name="name" value=“CSE-C STUDENTS" />
</jsp:forward>
</body>
</html>
welcome.jsp
<html>
<body>
<% out.print("Today is:"+java.util.Calendar.getInstance().getTime()); %>
<%= request.getParameter("name") %>
</body>
</html>
jsp:include action tag
• The jsp:include action tag is used to include the content of another resource it may
be jsp, html or servlet.
• The jsp include action tag includes the resource at request time so it is better for
dynamic pages because there might be changes in future.
• The jsp:include tag can be used to include static as well as dynamic pages.
Syntax of jsp:include action tag without parameter
<jsp:include page="relativeURL | <%= expression %>" />
Syntax of jsp:include action tag with parameter
<jsp:include page="relativeURL | <%= expression %>">
<jsp:param name="parametername" value="parametervalue | <%=expression%>" />
Example of jsp:include action tag without parameter
File: index.jsp
<h2>this is index page</h2>
<jsp:include page="printdate.jsp" />
<h2>end section of index page</h2>
File: printdate.jsp
<% out.print("Today is:"+java.util.Calendar.getInstance().getTime()); %>
THANK YOU

More Related Content

PPT
Jsp
Prabhat gangwar
 
PPT
Jsp
Manav Prasad
 
PPTX
JSP.pptx programming guide for beginners and experts
rani marri
 
PPTX
Java server pages
Farzad Wadia
 
PPT
Server side development on java server pages
vinitasharma749430
 
DOC
Jsp advance part i
sameersaxena90
 
PPTX
JSP_Complete_Guide_With_Step_By_Step_solution
powerofthehelios
 
PPTX
ADP - Chapter 5 Exploring JavaServer Pages Technology
Riza Nurman
 
JSP.pptx programming guide for beginners and experts
rani marri
 
Java server pages
Farzad Wadia
 
Server side development on java server pages
vinitasharma749430
 
Jsp advance part i
sameersaxena90
 
JSP_Complete_Guide_With_Step_By_Step_solution
powerofthehelios
 
ADP - Chapter 5 Exploring JavaServer Pages Technology
Riza Nurman
 

Similar to JSP Directives IMPLICIT ACTIONS and HACKING.pptx (20)

PPT
Jsp1
Soham Sengupta
 
PPTX
Introduction to JSP.pptx
ManishaPatil932723
 
PPTX
Jsp elements
Nuha Noor
 
PPT
Session 5 : intro to jsp - Giáo trình Bách Khoa Aptech
MasterCode.vn
 
PPTX
JSP AND XML USING JAVA WITH GET AND POST METHODS
bharathiv53
 
PPTX
Jsp
Pooja Verma
 
PPTX
Learning jsp
mustafacse2009
 
PDF
Jsp
Priya Goyal
 
PPTX
JSP Directives
ShahDhruv21
 
PDF
Lap trinh web [Slide jsp]
Tri Nguyen
 
PPTX
Session 37 - JSP - Part 2 (final)
PawanMM
 
PDF
Java Server Pages
Rami Nayan
 
PPTX
The java server pages
Atul Saurabh
 
PPTX
Jsp session 4
Anuj Singh Rajput
 
PPTX
JSP - Java Server Page
Vipin Yadav
 
PPSX
JSP - Part 2 (Final)
Hitesh-Java
 
PPTX
Introduction - Java Server Programming (JSP)
PadmavathiKPSGCAS
 
PPTX
WT Unit-Vuufvmjn dissimilating Dunkirk k
asta9578
 
PDF
Java Web Programming [4/9] : JSP Basic
IMC Institute
 
PPTX
SCWCD : Java server pages CHAP : 9
Ben Abdallah Helmi
 
Introduction to JSP.pptx
ManishaPatil932723
 
Jsp elements
Nuha Noor
 
Session 5 : intro to jsp - Giáo trình Bách Khoa Aptech
MasterCode.vn
 
JSP AND XML USING JAVA WITH GET AND POST METHODS
bharathiv53
 
Learning jsp
mustafacse2009
 
JSP Directives
ShahDhruv21
 
Lap trinh web [Slide jsp]
Tri Nguyen
 
Session 37 - JSP - Part 2 (final)
PawanMM
 
Java Server Pages
Rami Nayan
 
The java server pages
Atul Saurabh
 
Jsp session 4
Anuj Singh Rajput
 
JSP - Java Server Page
Vipin Yadav
 
JSP - Part 2 (Final)
Hitesh-Java
 
Introduction - Java Server Programming (JSP)
PadmavathiKPSGCAS
 
WT Unit-Vuufvmjn dissimilating Dunkirk k
asta9578
 
Java Web Programming [4/9] : JSP Basic
IMC Institute
 
SCWCD : Java server pages CHAP : 9
Ben Abdallah Helmi
 

More from yvtinsane (8)

PPT
vertopal.com_The-Power-of-Effective-Communication-in-Business-Growth-2.ppt
yvtinsane
 
PPTX
FAI - Unit 4 - Logic and Knowledges.pptx
yvtinsane
 
PPTX
FAI UNIT 3Search using games important.pptx
yvtinsane
 
PPT
Network Models computer networks important.ppt
yvtinsane
 
PPTX
IMPORTANT SESSION TRACKING TECHNIQUES.pptx
yvtinsane
 
PPTX
jsp elements java server tag with jsp elements .pptx
yvtinsane
 
PPTX
Lower bound theory Np hard & Np completeness
yvtinsane
 
PPTX
daa18d8d-d333-4398-94dd-a46802d88d79.pptx
yvtinsane
 
vertopal.com_The-Power-of-Effective-Communication-in-Business-Growth-2.ppt
yvtinsane
 
FAI - Unit 4 - Logic and Knowledges.pptx
yvtinsane
 
FAI UNIT 3Search using games important.pptx
yvtinsane
 
Network Models computer networks important.ppt
yvtinsane
 
IMPORTANT SESSION TRACKING TECHNIQUES.pptx
yvtinsane
 
jsp elements java server tag with jsp elements .pptx
yvtinsane
 
Lower bound theory Np hard & Np completeness
yvtinsane
 
daa18d8d-d333-4398-94dd-a46802d88d79.pptx
yvtinsane
 

Recently uploaded (20)

PPTX
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
PPTX
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PPTX
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
PDF
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
PPTX
CDH. pptx
AneetaSharma15
 
PPTX
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
PPTX
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
PPTX
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
PPTX
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
PPTX
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
PPTX
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
PPTX
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
PPTX
Basics and rules of probability with real-life uses
ravatkaran694
 
PPTX
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
PDF
Health-The-Ultimate-Treasure (1).pdf/8th class science curiosity /samyans edu...
Sandeep Swamy
 
PDF
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
PPTX
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
PPTX
How to Apply for a Job From Odoo 18 Website
Celine George
 
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
CDH. pptx
AneetaSharma15
 
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
Basics and rules of probability with real-life uses
ravatkaran694
 
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
Health-The-Ultimate-Treasure (1).pdf/8th class science curiosity /samyans edu...
Sandeep Swamy
 
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
How to Apply for a Job From Odoo 18 Website
Celine George
 

JSP Directives IMPLICIT ACTIONS and HACKING.pptx

  • 1. JSP Directives , Implicit Objects and Actions
  • 2. JSP DIRECTIVES • jsp directives are messages that tells the web container how to translate a JSP page into the corresponding servlet. • There are three types of directives: 1. page directive 2. include directive 3. taglib directive • Syntax: <%@ directive attribute="value" %>
  • 3. JSP page directive • The page directive defines attributes that apply to an entire JSP page. Syntax : <%@ page attribute="value" %> • Attributes of JSP page directive o import o contentType o extends o info o buffer o language o session o errorPage o isErrorPage
  • 4. 1) import The import attribute is used to import class,interface or all the members of a package.It is similar to import keyword in java class or interface Example of import attribute <html> <body> <%@ page import="java.util.Date" %> Today is: <%= new Date() %> </body> </html>
  • 5. 2) contentType • The contentType attribute defines the MIME(Multipurpose Internet Mail Extension) type of the HTTP response.The default value is "text/html;charset=ISO-8859-1". <html> <body> <%@ page contentType=application/msword %> Today is: <%= new java.util.Date() %> </body> </html>
  • 6. 3)info • This attribute simply sets the information of the JSP page which is retrieved later by using getServletInfo() method of Servlet interface <html> <body> <%@ page info="current Date will displayed" %> Today is: <%= new java.util.Date() %> </body>
  • 7. 4) errorPage • The errorPage attribute is used to define the error page, if exception occurs in the current page, it will be redirected to the error page. <html> <body> <%@ page errorPage="myerrorpage.jsp" %> <%= 100/0 %> </body> </html>
  • 8. isErrorPage • The isErrorPage attribute is used to declare that the current page is the error page. • Note: The exception object can only be used in the error page. <html> <body> <%@ page isErrorPage="true" %> Sorry an exception occured!<br/> The exception is: <%= exception %> </body> </html>
  • 9. JSP Include Directive • The include directive is used to include the contents of any resource it may be jsp file, html file or text file. The include directive includes the original content of the included resource at page translation time Advantage of Include directive • Code Reusability <%@ include file="resourceName" %>
  • 10. JSP Include Directive… <html> <body> <%@ include file="header.html" %> Today is: <%= java.util.Calendar.getInstance().getTime() %> </body> </html>
  • 11. JSP Implicit Objects • There are 9 jsp implicit objects. These objects are created by the web container that are available to all the jsp pages • Out • Request • Response • Session • Exception • Config • Appication • Page • PageContext
  • 12. JSP request implicit object • The JSP request is an implicit object of type HttpServletRequest i.e. created for each jsp request by the web container. It can be used to get request information such as parameter index.html <form action="welcome.jsp"> <input type="text" name="uname"> <input type="submit" value="go"><br/> </form> welcome.jsp <% String name=request.getParameter("uname"); out.print("welcome "+name); %>
  • 13. JSP response implicit object • In JSP, response is an implicit object of type HttpServletResponse. The instance of HttpServletResponse is created by the web container for each jsp request. index.html <form action="welcome.jsp"> <input type="text" name="uname"> <input type="submit" value="go"><br/> </form> welcome.jsp <% response.sendRedirect("http://www.google.com"); %>
  • 14. session implicit object • In JSP, session is an implicit object of type HttpSession.The Java developer can use this object to set,get or remove attribute or to get session information. index.html <html> <body> <form action="welcome.jsp"> <input type="text" name="uname"> <input type="submit" value="go"><br/> </form> </body> </html>
  • 17. exception implicit object • In JSP, exception is an implicit object of type java.lang.Throwable class. This object can be used to print the exception. But it can only be used in error pages.It is better to learn it after page error.jsp <%@ page isErrorPage="true" %> <html> <body> Sorry following exception occured:<%= exception %> </body> </html>
  • 18. ACTIONS • There are many JSP action tags or elements. Each JSP action tag is used to perform some specific tasks. • The action tags are used to control the flow between pages and to use Java Bean. The Jsp action tags are given below. JSP Action Tags Description jsp:forward forwards the request and response to another resource. jsp:include includes another resource. jsp:useBean creates or locates bean object. jsp:setProperty sets the value of property in bean object. jsp:getProperty prints the value of property of the bean. jsp:plugin embeds another components such as applet. jsp:param sets the parameter value. It is used in forward and include mostly.
  • 19. forward action tag • The jsp:forward action tag is used to forward the request to another resource it may be jsp, html or another resource. Syntax of jsp:forward action tag without parameter <jsp:forward page="relativeURL | <%= expression %>" /> Syntax of jsp:forward action tag with parameter <jsp:forward page="relativeURL | <%= expression %>"> <jsp:param name="parametername" value="parametervalue | <%=expression%>" /> </jsp:forward>
  • 20. Example of jsp:forward action tag without parameter index.jsp <html> <body> <h2>This is first page</h2> <jsp:forward page="printdate.jsp" /> </body> </html> printdate.jsp <html> <body> <% out.print(“Anurag University”)%> </body> </html>
  • 21. Example of jsp:forward action tag with parameter index.jsp <html> <body> <h2>this is index page</h2> <jsp:forward page=“welcome.jsp" > <jsp:param name="name" value=“CSE-C STUDENTS" /> </jsp:forward> </body> </html> welcome.jsp <html> <body> <% out.print("Today is:"+java.util.Calendar.getInstance().getTime()); %> <%= request.getParameter("name") %> </body> </html>
  • 22. jsp:include action tag • The jsp:include action tag is used to include the content of another resource it may be jsp, html or servlet. • The jsp include action tag includes the resource at request time so it is better for dynamic pages because there might be changes in future. • The jsp:include tag can be used to include static as well as dynamic pages. Syntax of jsp:include action tag without parameter <jsp:include page="relativeURL | <%= expression %>" /> Syntax of jsp:include action tag with parameter <jsp:include page="relativeURL | <%= expression %>"> <jsp:param name="parametername" value="parametervalue | <%=expression%>" />
  • 23. Example of jsp:include action tag without parameter File: index.jsp <h2>this is index page</h2> <jsp:include page="printdate.jsp" /> <h2>end section of index page</h2> File: printdate.jsp <% out.print("Today is:"+java.util.Calendar.getInstance().getTime()); %>