SlideShare a Scribd company logo
1 of 24
Download to read offline
Web Component Development
with Servlet & JSP Technologies
(EE 6)
Module-7: Developing JSP Pages
www.webstackacademy.com
Objectives
Upon completion of this module, you should be able
to:
● Describe JSP page technology
● Write JSP code using scripting elements
● Write JSP code using the page directive
● Write JSP code using standard tags
● Write JSP code using the EL
● Configure the JSP page environment in the web.xml
file
www.webstackacademy.com
Relevance
Discussion – The following questions are relevant to
understanding JSP technology:
● What problems exist in generating an HTML response
in a servlet?
● How do template page technologies (and JSP
technology in
particular) solve these problems?
www.webstackacademy.com
How a JSP Page Is
Processed
A JSP page is essentially source code, and must be converted into a
servlet before it can service requests. Figure shows the steps of JSP
page processing.
www.webstackacademy.com
Writing JSP Scripting
Elements
JSP scripting elements are embedded with the <% %> tags and are
processed by the JSP engine during translation of the JSP page. Any
other
text in the JSP page is considered part of the response and is copied
verbatim to the HTTP response stream that is sent to the web
browser.
<html>
<%-- scripting element --%>
</html>
www.webstackacademy.com
Writing JSP
Scripting Elements
www.webstackacademy.com
Comments
HTML Comment:
<!-- This is an HTML comment. It will show up in the response. -->
JSP Comment:
<%-- This is a JSP comment. It will only be seen in the JSP m code.
It will not show up in either the servlet code or the response.--%>
Java Comment:
<%
/* This is java comment and it will only be seen in servlet.It will not
show in response. */
%>
www.webstackacademy.com
Implicit Variables
The JSP engine gives you access to the following implicit
variables, also called implicit objects, in scriptlet and
expression tags. These variables represent commonly
used objects for servlets that JSP page developers might
need to use. For example, you can retrieve HTML form
parameter data by using the request variable, which
represents the HttpServletRequest object.
www.webstackacademy.com
Implicit Variables
Request
Response
Out
Session
Application
Config
PageContext
Page
Exception
www.webstackacademy.com
Using the page
Directive
You use the page directive to modify the overall
translation of the JSP page. For example, you can
declare that the servlet code generated from a JSP
page requires the use of the Date class:
<%@ page import=”java.util.Date” %>
www.webstackacademy.com
Including JSP Page
Segments
There are two standard approaches to including
presentation segments in your JSP pages:
● The include directive
● The jsp:include standard action
www.webstackacademy.com
Using the include
Directive
The include directive lets you include a segment in the text
of the main JSP page at translation time. The syntax of this
JSP technology directive is as follows:
<%@ include file=”segmentURL” %>
www.webstackacademy.com
Using Standard Tags
● The JSP specification provides standard tags for use
within your JSP pages. Because these tags are
required in the specification, every JSP container
must support them. This ensures that any
applications using the standard tags will work in any
compliant JSP container.
● Standard tags begin with the jsp: prefix. You use
these tags to reduce or eliminate scriptlet code
within your JSP page. However, the standard tags
only provide limited functionality. Using the JSTL and
EL reduces the need for the standard tags.
www.webstackacademy.com
JavaBeans
Components
A JavaBeans component is a Java technology class with at
minimum the following features:
● Properties defined with accessors and mutators (get and
set methods).
● A no-argument constructor.
● No public instance variables.
● The class implements the java.io.Serializable interface.
www.webstackacademy.com
The useBean Tag
If you want to interact with a JavaBeans component using the
standard
tags in a JSP page, you must first declare the bean. You do this
by using
the useBean standard tag.
The syntax of the useBean tag is as follows:
<jsp:useBean id=”beanName”
scope=”page | request | session | application”
class=”className” />
The id attribute specifies the attribute name of the bean. Where
the bean is stored is specified by the scope attribute. Scope
defaults to page if not specified. The class attribute specifies the
fully qualified class name.
www.webstackacademy.com
The setProperty Tag
● You use the setProperty tag to store data in the JavaBeans
instance. The syntax of the setProperty tag is as follows:
<jsp:setProperty name="beanName" property_expression/>
● The property attribute specifies the property within the bean that
will be set. For example, to set the email property in the customer
bean, you can use the following:
<jsp:setProperty name=”cust” property=”email” />
www.webstackacademy.com
The getProperty Tag
The getProperty tag is used to retrieve a property from a
JavaBeans instance and display it in the output stream.
The syntax of the getProperty tag is as follows:
<jsp:getProperty name=”beanName”
property=”propertyName” />
The name attribute specifies the name of the JavaBeans instance
and the property attribute specifies the property used for the get
method.
Given a getProperty usage of the following:
<jsp:getProperty name=”cust” property=”email” />
www.webstackacademy.com
Other Standard Tags
www.webstackacademy.com
Other Standard Tags
www.webstackacademy.com
Using the jsp:include
Standard Action
● The jsp:include standard action lets you include a segment
in the text of the main JSP page at runtime. The syntax of
this JSP technology action tag is as follows:
<jsp:include page=”segmentURL” />
● You might have noticed that the include directive uses an
attribute called file and the jsp:include standard action uses
an attribute called page. These attributes represent the
same concept: The URL to the segment file to be included.
● The jsp:include action is equivalent to using the include
method on a RequestDispatcher object. For example:
RequestDispatcher segment =
request.getRequestDispatcher(page);
segment.include(request, response);
www.webstackacademy.com
Using the jsp:include
Standard Action
● The jsp:include standard action lets you include a segment
in the text of the main JSP page at runtime. The syntax of
this JSP technology action tag is as follows:
<jsp:include page=”segmentURL” />
● You might have noticed that the include directive uses an
attribute called file and the jsp:include standard action uses
an attribute called page. These attributes represent the
same concept: The URL to the segment file to be included.
● The jsp:include action is equivalent to using the include
method on a RequestDispatcher object. For example:
RequestDispatcher segment =
request.getRequestDispatcher(page);
segment.include(request, response);
www.webstackacademy.com
Using the jsp:param
Standard Action
Sometimes, you might want to alter a presentation
segment at runtime.
The jsp:include action lets you pass additional
parameters to the presentation segment at runtime
using the jsp:param standard action. The syntax of
this JSP technology action tag and the relationship to
the jsp:include action is:
<jsp:include page=”segmentURL”>
<jsp:param name=”paramName”
value=”paramValue”/>
</jsp:include>
www.webstackacademy.com
Using the jsp:param
Standard Action
<!-- START of banner -->
<jsp:include page=”/WEB-INF/view/common/banner.jsp”>
<jsp:param name=”subTitle” value=”Registration” />
</jsp:include>
<!-- END of banner -->
Web Stack Academy (P) Ltd
#83, Farah Towers,
1st floor,MG Road,
Bangalore – 560001
M: +91-80-4128 9576
T: +91-98862 69112
E: info@www.webstackacademy.com
www.webstackacademy.com

More Related Content

What's hot (20)

Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Implicit objects advance Java
Implicit objects advance JavaImplicit objects advance Java
Implicit objects advance Java
 
JSP
JSPJSP
JSP
 
Jsp element
Jsp elementJsp element
Jsp element
 
Jsp presentation
Jsp presentationJsp presentation
Jsp presentation
 
Jsp chapter 1
Jsp chapter 1Jsp chapter 1
Jsp chapter 1
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
 
JAVA SERVER PAGES
JAVA SERVER PAGESJAVA SERVER PAGES
JAVA SERVER PAGES
 
Servlets and jsp pages best practices
Servlets and jsp pages best practicesServlets and jsp pages best practices
Servlets and jsp pages best practices
 
Jsp
JspJsp
Jsp
 
Implicit object.pptx
Implicit object.pptxImplicit object.pptx
Implicit object.pptx
 
Jsp tutorial (1)
Jsp tutorial (1)Jsp tutorial (1)
Jsp tutorial (1)
 
Jsp Introduction Tutorial
Jsp Introduction TutorialJsp Introduction Tutorial
Jsp Introduction Tutorial
 
Jsp and jstl
Jsp and jstlJsp and jstl
Jsp and jstl
 
JSP - Java Server Page
JSP - Java Server PageJSP - Java Server Page
JSP - Java Server Page
 
Intro To Sap Netweaver Java
Intro To Sap Netweaver JavaIntro To Sap Netweaver Java
Intro To Sap Netweaver Java
 
Jsp (java server page)
Jsp (java server page)Jsp (java server page)
Jsp (java server page)
 
Web&java. jsp
Web&java. jspWeb&java. jsp
Web&java. jsp
 
Java server pages
Java server pagesJava server pages
Java server pages
 
Java server pages
Java server pagesJava server pages
Java server pages
 

Similar to Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 - Developing JSP Pages

Similar to Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 - Developing JSP Pages (20)

Jsp in Servlet by Rj
Jsp in Servlet by RjJsp in Servlet by Rj
Jsp in Servlet by Rj
 
Introduction to JSP.pptx
Introduction to JSP.pptxIntroduction to JSP.pptx
Introduction to JSP.pptx
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
JSP.pptx
JSP.pptxJSP.pptx
JSP.pptx
 
SCWCD : Java server pages CHAP : 9
SCWCD : Java server pages  CHAP : 9SCWCD : Java server pages  CHAP : 9
SCWCD : Java server pages CHAP : 9
 
JSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESJSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGES
 
JSP Technology I
JSP Technology IJSP Technology I
JSP Technology I
 
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
 
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
 
JSP Part 2
JSP Part 2JSP Part 2
JSP Part 2
 
3.jsp tutorial
3.jsp tutorial3.jsp tutorial
3.jsp tutorial
 
JSP Directives
JSP DirectivesJSP Directives
JSP Directives
 
Jsp
JspJsp
Jsp
 
Jsp
JspJsp
Jsp
 
Jsp tutorial
Jsp tutorialJsp tutorial
Jsp tutorial
 
Learning jsp
Learning jspLearning jsp
Learning jsp
 
Jsp Presentation +Mufix "3"
Jsp Presentation +Mufix "3"Jsp Presentation +Mufix "3"
Jsp Presentation +Mufix "3"
 
4. jsp
4. jsp4. jsp
4. jsp
 
J2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsJ2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - Components
 
Lap trinh web [Slide jsp]
Lap trinh web [Slide jsp]Lap trinh web [Slide jsp]
Lap trinh web [Slide jsp]
 

More from WebStackAcademy

Webstack Academy - Course Demo Webinar and Placement Journey
Webstack Academy - Course Demo Webinar and Placement JourneyWebstack Academy - Course Demo Webinar and Placement Journey
Webstack Academy - Course Demo Webinar and Placement JourneyWebStackAcademy
 
WSA: Scaling Web Service to Handle Millions of Requests per Second
WSA: Scaling Web Service to Handle Millions of Requests per SecondWSA: Scaling Web Service to Handle Millions of Requests per Second
WSA: Scaling Web Service to Handle Millions of Requests per SecondWebStackAcademy
 
WSA: Course Demo Webinar - Full Stack Developer Course
WSA: Course Demo Webinar - Full Stack Developer CourseWSA: Course Demo Webinar - Full Stack Developer Course
WSA: Course Demo Webinar - Full Stack Developer CourseWebStackAcademy
 
Career Building in AI - Technologies, Trends and Opportunities
Career Building in AI - Technologies, Trends and OpportunitiesCareer Building in AI - Technologies, Trends and Opportunities
Career Building in AI - Technologies, Trends and OpportunitiesWebStackAcademy
 
Webstack Academy - Internship Kick Off
Webstack Academy - Internship Kick OffWebstack Academy - Internship Kick Off
Webstack Academy - Internship Kick OffWebStackAcademy
 
Building Your Online Portfolio
Building Your Online PortfolioBuilding Your Online Portfolio
Building Your Online PortfolioWebStackAcademy
 
Front-End Developer's Career Roadmap
Front-End Developer's Career RoadmapFront-End Developer's Career Roadmap
Front-End Developer's Career RoadmapWebStackAcademy
 
Angular - Chapter 9 - Authentication and Authorization
Angular - Chapter 9 - Authentication and AuthorizationAngular - Chapter 9 - Authentication and Authorization
Angular - Chapter 9 - Authentication and AuthorizationWebStackAcademy
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesWebStackAcademy
 
Angular - Chapter 6 - Firebase Integration
Angular - Chapter 6 - Firebase IntegrationAngular - Chapter 6 - Firebase Integration
Angular - Chapter 6 - Firebase IntegrationWebStackAcademy
 
Angular - Chapter 5 - Directives
 Angular - Chapter 5 - Directives Angular - Chapter 5 - Directives
Angular - Chapter 5 - DirectivesWebStackAcademy
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event HandlingWebStackAcademy
 
Angular - Chapter 3 - Components
Angular - Chapter 3 - ComponentsAngular - Chapter 3 - Components
Angular - Chapter 3 - ComponentsWebStackAcademy
 
Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming WebStackAcademy
 
Angular - Chapter 1 - Introduction
 Angular - Chapter 1 - Introduction Angular - Chapter 1 - Introduction
Angular - Chapter 1 - IntroductionWebStackAcademy
 
JavaScript - Chapter 10 - Strings and Arrays
 JavaScript - Chapter 10 - Strings and Arrays JavaScript - Chapter 10 - Strings and Arrays
JavaScript - Chapter 10 - Strings and ArraysWebStackAcademy
 
JavaScript - Chapter 15 - Debugging Techniques
 JavaScript - Chapter 15 - Debugging Techniques JavaScript - Chapter 15 - Debugging Techniques
JavaScript - Chapter 15 - Debugging TechniquesWebStackAcademy
 
JavaScript - Chapter 14 - Form Handling
 JavaScript - Chapter 14 - Form Handling   JavaScript - Chapter 14 - Form Handling
JavaScript - Chapter 14 - Form Handling WebStackAcademy
 
JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)WebStackAcademy
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object ModelWebStackAcademy
 

More from WebStackAcademy (20)

Webstack Academy - Course Demo Webinar and Placement Journey
Webstack Academy - Course Demo Webinar and Placement JourneyWebstack Academy - Course Demo Webinar and Placement Journey
Webstack Academy - Course Demo Webinar and Placement Journey
 
WSA: Scaling Web Service to Handle Millions of Requests per Second
WSA: Scaling Web Service to Handle Millions of Requests per SecondWSA: Scaling Web Service to Handle Millions of Requests per Second
WSA: Scaling Web Service to Handle Millions of Requests per Second
 
WSA: Course Demo Webinar - Full Stack Developer Course
WSA: Course Demo Webinar - Full Stack Developer CourseWSA: Course Demo Webinar - Full Stack Developer Course
WSA: Course Demo Webinar - Full Stack Developer Course
 
Career Building in AI - Technologies, Trends and Opportunities
Career Building in AI - Technologies, Trends and OpportunitiesCareer Building in AI - Technologies, Trends and Opportunities
Career Building in AI - Technologies, Trends and Opportunities
 
Webstack Academy - Internship Kick Off
Webstack Academy - Internship Kick OffWebstack Academy - Internship Kick Off
Webstack Academy - Internship Kick Off
 
Building Your Online Portfolio
Building Your Online PortfolioBuilding Your Online Portfolio
Building Your Online Portfolio
 
Front-End Developer's Career Roadmap
Front-End Developer's Career RoadmapFront-End Developer's Career Roadmap
Front-End Developer's Career Roadmap
 
Angular - Chapter 9 - Authentication and Authorization
Angular - Chapter 9 - Authentication and AuthorizationAngular - Chapter 9 - Authentication and Authorization
Angular - Chapter 9 - Authentication and Authorization
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP Services
 
Angular - Chapter 6 - Firebase Integration
Angular - Chapter 6 - Firebase IntegrationAngular - Chapter 6 - Firebase Integration
Angular - Chapter 6 - Firebase Integration
 
Angular - Chapter 5 - Directives
 Angular - Chapter 5 - Directives Angular - Chapter 5 - Directives
Angular - Chapter 5 - Directives
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
 
Angular - Chapter 3 - Components
Angular - Chapter 3 - ComponentsAngular - Chapter 3 - Components
Angular - Chapter 3 - Components
 
Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming
 
Angular - Chapter 1 - Introduction
 Angular - Chapter 1 - Introduction Angular - Chapter 1 - Introduction
Angular - Chapter 1 - Introduction
 
JavaScript - Chapter 10 - Strings and Arrays
 JavaScript - Chapter 10 - Strings and Arrays JavaScript - Chapter 10 - Strings and Arrays
JavaScript - Chapter 10 - Strings and Arrays
 
JavaScript - Chapter 15 - Debugging Techniques
 JavaScript - Chapter 15 - Debugging Techniques JavaScript - Chapter 15 - Debugging Techniques
JavaScript - Chapter 15 - Debugging Techniques
 
JavaScript - Chapter 14 - Form Handling
 JavaScript - Chapter 14 - Form Handling   JavaScript - Chapter 14 - Form Handling
JavaScript - Chapter 14 - Form Handling
 
JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
 

Recently uploaded

"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 

Recently uploaded (20)

"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 

Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 - Developing JSP Pages

  • 1. Web Component Development with Servlet & JSP Technologies (EE 6) Module-7: Developing JSP Pages
  • 2. www.webstackacademy.com Objectives Upon completion of this module, you should be able to: ● Describe JSP page technology ● Write JSP code using scripting elements ● Write JSP code using the page directive ● Write JSP code using standard tags ● Write JSP code using the EL ● Configure the JSP page environment in the web.xml file
  • 3. www.webstackacademy.com Relevance Discussion – The following questions are relevant to understanding JSP technology: ● What problems exist in generating an HTML response in a servlet? ● How do template page technologies (and JSP technology in particular) solve these problems?
  • 4. www.webstackacademy.com How a JSP Page Is Processed A JSP page is essentially source code, and must be converted into a servlet before it can service requests. Figure shows the steps of JSP page processing.
  • 5. www.webstackacademy.com Writing JSP Scripting Elements JSP scripting elements are embedded with the <% %> tags and are processed by the JSP engine during translation of the JSP page. Any other text in the JSP page is considered part of the response and is copied verbatim to the HTTP response stream that is sent to the web browser. <html> <%-- scripting element --%> </html>
  • 7. www.webstackacademy.com Comments HTML Comment: <!-- This is an HTML comment. It will show up in the response. --> JSP Comment: <%-- This is a JSP comment. It will only be seen in the JSP m code. It will not show up in either the servlet code or the response.--%> Java Comment: <% /* This is java comment and it will only be seen in servlet.It will not show in response. */ %>
  • 8. www.webstackacademy.com Implicit Variables The JSP engine gives you access to the following implicit variables, also called implicit objects, in scriptlet and expression tags. These variables represent commonly used objects for servlets that JSP page developers might need to use. For example, you can retrieve HTML form parameter data by using the request variable, which represents the HttpServletRequest object.
  • 10. www.webstackacademy.com Using the page Directive You use the page directive to modify the overall translation of the JSP page. For example, you can declare that the servlet code generated from a JSP page requires the use of the Date class: <%@ page import=”java.util.Date” %>
  • 11. www.webstackacademy.com Including JSP Page Segments There are two standard approaches to including presentation segments in your JSP pages: ● The include directive ● The jsp:include standard action
  • 12. www.webstackacademy.com Using the include Directive The include directive lets you include a segment in the text of the main JSP page at translation time. The syntax of this JSP technology directive is as follows: <%@ include file=”segmentURL” %>
  • 13. www.webstackacademy.com Using Standard Tags ● The JSP specification provides standard tags for use within your JSP pages. Because these tags are required in the specification, every JSP container must support them. This ensures that any applications using the standard tags will work in any compliant JSP container. ● Standard tags begin with the jsp: prefix. You use these tags to reduce or eliminate scriptlet code within your JSP page. However, the standard tags only provide limited functionality. Using the JSTL and EL reduces the need for the standard tags.
  • 14. www.webstackacademy.com JavaBeans Components A JavaBeans component is a Java technology class with at minimum the following features: ● Properties defined with accessors and mutators (get and set methods). ● A no-argument constructor. ● No public instance variables. ● The class implements the java.io.Serializable interface.
  • 15. www.webstackacademy.com The useBean Tag If you want to interact with a JavaBeans component using the standard tags in a JSP page, you must first declare the bean. You do this by using the useBean standard tag. The syntax of the useBean tag is as follows: <jsp:useBean id=”beanName” scope=”page | request | session | application” class=”className” /> The id attribute specifies the attribute name of the bean. Where the bean is stored is specified by the scope attribute. Scope defaults to page if not specified. The class attribute specifies the fully qualified class name.
  • 16. www.webstackacademy.com The setProperty Tag ● You use the setProperty tag to store data in the JavaBeans instance. The syntax of the setProperty tag is as follows: <jsp:setProperty name="beanName" property_expression/> ● The property attribute specifies the property within the bean that will be set. For example, to set the email property in the customer bean, you can use the following: <jsp:setProperty name=”cust” property=”email” />
  • 17. www.webstackacademy.com The getProperty Tag The getProperty tag is used to retrieve a property from a JavaBeans instance and display it in the output stream. The syntax of the getProperty tag is as follows: <jsp:getProperty name=”beanName” property=”propertyName” /> The name attribute specifies the name of the JavaBeans instance and the property attribute specifies the property used for the get method. Given a getProperty usage of the following: <jsp:getProperty name=”cust” property=”email” />
  • 20. www.webstackacademy.com Using the jsp:include Standard Action ● The jsp:include standard action lets you include a segment in the text of the main JSP page at runtime. The syntax of this JSP technology action tag is as follows: <jsp:include page=”segmentURL” /> ● You might have noticed that the include directive uses an attribute called file and the jsp:include standard action uses an attribute called page. These attributes represent the same concept: The URL to the segment file to be included. ● The jsp:include action is equivalent to using the include method on a RequestDispatcher object. For example: RequestDispatcher segment = request.getRequestDispatcher(page); segment.include(request, response);
  • 21. www.webstackacademy.com Using the jsp:include Standard Action ● The jsp:include standard action lets you include a segment in the text of the main JSP page at runtime. The syntax of this JSP technology action tag is as follows: <jsp:include page=”segmentURL” /> ● You might have noticed that the include directive uses an attribute called file and the jsp:include standard action uses an attribute called page. These attributes represent the same concept: The URL to the segment file to be included. ● The jsp:include action is equivalent to using the include method on a RequestDispatcher object. For example: RequestDispatcher segment = request.getRequestDispatcher(page); segment.include(request, response);
  • 22. www.webstackacademy.com Using the jsp:param Standard Action Sometimes, you might want to alter a presentation segment at runtime. The jsp:include action lets you pass additional parameters to the presentation segment at runtime using the jsp:param standard action. The syntax of this JSP technology action tag and the relationship to the jsp:include action is: <jsp:include page=”segmentURL”> <jsp:param name=”paramName” value=”paramValue”/> </jsp:include>
  • 23. www.webstackacademy.com Using the jsp:param Standard Action <!-- START of banner --> <jsp:include page=”/WEB-INF/view/common/banner.jsp”> <jsp:param name=”subTitle” value=”Registration” /> </jsp:include> <!-- END of banner -->
  • 24. Web Stack Academy (P) Ltd #83, Farah Towers, 1st floor,MG Road, Bangalore – 560001 M: +91-80-4128 9576 T: +91-98862 69112 E: info@www.webstackacademy.com www.webstackacademy.com