SlideShare a Scribd company logo
JSP
• JSP technology is used to create web application
just like Servlet technology. It can be thought of
as an extension to Servlet because it provides
more functionality than servlet such as
expression language, etc.
• A JSP page consists of HTML tags and JSP tags.
The JSP pages are easier to maintain than Servlet
because we can separate designing and
development. It provides some additional
features such as Expression Language, Custom
Tags, etc.
Advantages of JSP over Servlet
1) Extension to Servlet
JSP technology is the extension to Servlet technology. We can use all the
features of the Servlet in JSP. In addition to, we can use implicit objects,
predefined tags, expression language and Custom tags in JSP, that makes
JSP development easy.
2) Easy to maintain
JSP can be easily managed because we can easily separate our business
logic with presentation logic. In Servlet technology, we mix our business
logic with the presentation logic.
3) Fast Development:
If JSP page is modified, we don't need to recompile and redeploy the
project. The Servlet code needs to be updated and recompiled if we have
to change the look and feel of the application.
4) Less code than Servlet
In JSP, we can use many tags such as action tags, custom tags, etc. that
reduces the code. Moreover, we can use implicit objects, etc.
The Lifecycle of a JSP Page
• Translation of JSP Page
• Compilation of JSP Page
• Classloading (the classloader loads class file)
• Instantiation (Object of the Generated Servlet is
created).
• Initialization ( the container invokes jspInit() method).
• Request processing ( the container invokes
_jspService() method).
• Destroy ( the container invokes jspDestroy() method).
• Note: jspInit(), _jspService() and jspDestroy() are the
life cycle methods of JSP.
• JSP page is translated into
Servlet by the help of JSP
translator.
• The JSP translator is a part of
the web server which is
responsible for translating
the JSP page into Servlet.
• After that, Servlet page is
compiled by the compiler and
gets converted into the class
file.
• Moreover, all the processes
that happen in Servlet are
performed on JSP later like
initialization, committing
response to the browser and
destroy.
JSP Declarations
• The JSP page that we write is turned into class
definition.
• When we declare a variable or method in jsp
inside Declaration Tag.
• We can declare static member, instance
variable and methods inside declaration Tag.
• Syntax
<%!Declaration code %>
JSP directives
• The 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:
• page directive
• include directive
• taglib directive
• Syntax of JSP Directive
• <%@ directive attribute="value" %>
JSP page directive
• The page directive defines attributes that
apply to an entire JSP page.
• Syntax of JSP page directive
• <%@ page attribute="value" %>
• Attributes of JSP page directive
• Import, contentType, extends,info
• Buffer, language, isThreadSafe
• autoFlush, session, pageEncoding
• errorPage, isErrorPage
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 (the jsp page is translated only
once so it will be better to include static resource).
• Advantage of Include directive
• Code Reusability
• Syntax of include directive
• <%@ include file="resourceName" %>
JSP Taglib directive
• The JSP taglib directive is used to define a tag
library that defines many tags. We use the TLD
(Tag Library Descriptor) file to define the tags.
In the custom tag section we will use this tag
so it will be better to learn it in custom tag.
• Syntax JSP Taglib directive
• <
%@ taglib uri="uriofthetaglibrary" prefix="pre
fixoftaglibrary" %>
JSP expression
• The code placed within JSP expression
tag is written to the output stream of the
response. So you need not write out.print() to
write data. It is mainly used to print the values
of variable or method.
• Syntax of JSP expression tag
• <%= statement %>
JSP scriptlet/Snippets
• A scriptlet tag is used to execute java source
code in JSP.
• The code that appears between the <%and%>
delimiters is called snippets.
• Syntax
• <% java source code %>
JSP Implicit Objects
• The Implicit objects are predefined variables used to
access request and application data.
• These objects are used by the scripting elements.
JSP Session tracking
• In a web application, server may be responding
to several clients at a time so session tracking
is a way by which a server can identify the
client.
• As we know HTTP protocol is stateless which
means client needs to open a separate
connection every time it interacts with server
and server treats each request as a new
request.
Session Tracking Techniques
• There are four techniques which can be used
to identify a user session.
• a) Cookies
• b) Hidden Fields
• c) URL Rewriting
• d) Session Object
• Cookie
• Cookie is a key value pair of information, sent by the server to the browser
and then browser sends back this identifier to the server with every
request
• Hidden Field
• Hidden fields are similar to other input fields with the only difference is
that these fields are not displayed on the page but its value is sent as
other input fields
• URL Rewriting
• URL Rewriting is the approach in which a session (unique) identifier gets
appended with each request URL so server can identify the user session.
• Session Object
• Session object is representation of a user session. User Session starts
when a user opens a browser and sends the first request to server. Session
object is available in all the request (in entire user session) so attributes
stored in Http session in will be available in any servlet or in a jsp.

More Related Content

PPTX
Java Server Pages
PPTX
Web programming-Introduction to JSP.pptx
PPTX
PPTX
Jsp basic
PPTX
presentation on online movie ticket booking
PPTX
Wt unit 4
PPTX
Core web application development
PDF
Enterprise java unit-3_chapter-1-jsp
Java Server Pages
Web programming-Introduction to JSP.pptx
Jsp basic
presentation on online movie ticket booking
Wt unit 4
Core web application development
Enterprise java unit-3_chapter-1-jsp

Similar to java server pages directives and processing (20)

PPTX
jsp elements java server tag with jsp elements .pptx
PPTX
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
PDF
PPTX
JavaScript, often abbreviated as JS, is a programming language and core techn...
PPT
Project First presentation about introduction to technologies to be used
DOC
Spatial approximate string search Doc
PPTX
21CS642 Module 4_2 JSP PPT.pptx VI SEM CSE
PPTX
SCWCD : Java server pages CHAP : 9
PDF
PPT
Module 4.pptModule 4.pptModule 4.pptModule 4.ppt
PDF
005432796.pdf
PPTX
Jsp session 1
PPT
JSP 1.pptdfdfdfdsfdsfdsfdsfdsgdgdgdgdgdd
PPTX
Web Technology Part 2
PPTX
JSP Directives
PPTX
Jsp Introduction Tutorial
PPT
Jsp abes new
PPTX
Java Server Pages
PPTX
BITM3730Week12.pptx
jsp elements java server tag with jsp elements .pptx
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
JavaScript, often abbreviated as JS, is a programming language and core techn...
Project First presentation about introduction to technologies to be used
Spatial approximate string search Doc
21CS642 Module 4_2 JSP PPT.pptx VI SEM CSE
SCWCD : Java server pages CHAP : 9
Module 4.pptModule 4.pptModule 4.pptModule 4.ppt
005432796.pdf
Jsp session 1
JSP 1.pptdfdfdfdsfdsfdsfdsfdsgdgdgdgdgdd
Web Technology Part 2
JSP Directives
Jsp Introduction Tutorial
Jsp abes new
Java Server Pages
BITM3730Week12.pptx
Ad

Recently uploaded (20)

PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Classroom Observation Tools for Teachers
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Basic Mud Logging Guide for educational purpose
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
01-Introduction-to-Information-Management.pdf
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
Pharma ospi slides which help in ospi learning
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
RMMM.pdf make it easy to upload and study
Module 4: Burden of Disease Tutorial Slides S2 2025
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Classroom Observation Tools for Teachers
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Complications of Minimal Access Surgery at WLH
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Microbial disease of the cardiovascular and lymphatic systems
Renaissance Architecture: A Journey from Faith to Humanism
Basic Mud Logging Guide for educational purpose
STATICS OF THE RIGID BODIES Hibbelers.pdf
01-Introduction-to-Information-Management.pdf
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
Anesthesia in Laparoscopic Surgery in India
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPH.pptx obstetrics and gynecology in nursing
Pharma ospi slides which help in ospi learning
TR - Agricultural Crops Production NC III.pdf
RMMM.pdf make it easy to upload and study
Ad

java server pages directives and processing

  • 1. JSP
  • 2. • JSP technology is used to create web application just like Servlet technology. It can be thought of as an extension to Servlet because it provides more functionality than servlet such as expression language, etc. • A JSP page consists of HTML tags and JSP tags. The JSP pages are easier to maintain than Servlet because we can separate designing and development. It provides some additional features such as Expression Language, Custom Tags, etc.
  • 3. Advantages of JSP over Servlet 1) Extension to Servlet JSP technology is the extension to Servlet technology. We can use all the features of the Servlet in JSP. In addition to, we can use implicit objects, predefined tags, expression language and Custom tags in JSP, that makes JSP development easy. 2) Easy to maintain JSP can be easily managed because we can easily separate our business logic with presentation logic. In Servlet technology, we mix our business logic with the presentation logic. 3) Fast Development: If JSP page is modified, we don't need to recompile and redeploy the project. The Servlet code needs to be updated and recompiled if we have to change the look and feel of the application. 4) Less code than Servlet In JSP, we can use many tags such as action tags, custom tags, etc. that reduces the code. Moreover, we can use implicit objects, etc.
  • 4. The Lifecycle of a JSP Page • Translation of JSP Page • Compilation of JSP Page • Classloading (the classloader loads class file) • Instantiation (Object of the Generated Servlet is created). • Initialization ( the container invokes jspInit() method). • Request processing ( the container invokes _jspService() method). • Destroy ( the container invokes jspDestroy() method). • Note: jspInit(), _jspService() and jspDestroy() are the life cycle methods of JSP.
  • 5. • JSP page is translated into Servlet by the help of JSP translator. • The JSP translator is a part of the web server which is responsible for translating the JSP page into Servlet. • After that, Servlet page is compiled by the compiler and gets converted into the class file. • Moreover, all the processes that happen in Servlet are performed on JSP later like initialization, committing response to the browser and destroy.
  • 6. JSP Declarations • The JSP page that we write is turned into class definition. • When we declare a variable or method in jsp inside Declaration Tag. • We can declare static member, instance variable and methods inside declaration Tag. • Syntax <%!Declaration code %>
  • 7. JSP directives • The 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: • page directive • include directive • taglib directive • Syntax of JSP Directive • <%@ directive attribute="value" %>
  • 8. JSP page directive • The page directive defines attributes that apply to an entire JSP page. • Syntax of JSP page directive • <%@ page attribute="value" %> • Attributes of JSP page directive • Import, contentType, extends,info • Buffer, language, isThreadSafe • autoFlush, session, pageEncoding • errorPage, isErrorPage
  • 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 (the jsp page is translated only once so it will be better to include static resource). • Advantage of Include directive • Code Reusability • Syntax of include directive • <%@ include file="resourceName" %>
  • 10. JSP Taglib directive • The JSP taglib directive is used to define a tag library that defines many tags. We use the TLD (Tag Library Descriptor) file to define the tags. In the custom tag section we will use this tag so it will be better to learn it in custom tag. • Syntax JSP Taglib directive • < %@ taglib uri="uriofthetaglibrary" prefix="pre fixoftaglibrary" %>
  • 11. JSP expression • The code placed within JSP expression tag is written to the output stream of the response. So you need not write out.print() to write data. It is mainly used to print the values of variable or method. • Syntax of JSP expression tag • <%= statement %>
  • 12. JSP scriptlet/Snippets • A scriptlet tag is used to execute java source code in JSP. • The code that appears between the <%and%> delimiters is called snippets. • Syntax • <% java source code %>
  • 13. JSP Implicit Objects • The Implicit objects are predefined variables used to access request and application data. • These objects are used by the scripting elements.
  • 14. JSP Session tracking • In a web application, server may be responding to several clients at a time so session tracking is a way by which a server can identify the client. • As we know HTTP protocol is stateless which means client needs to open a separate connection every time it interacts with server and server treats each request as a new request.
  • 15. Session Tracking Techniques • There are four techniques which can be used to identify a user session. • a) Cookies • b) Hidden Fields • c) URL Rewriting • d) Session Object
  • 16. • Cookie • Cookie is a key value pair of information, sent by the server to the browser and then browser sends back this identifier to the server with every request • Hidden Field • Hidden fields are similar to other input fields with the only difference is that these fields are not displayed on the page but its value is sent as other input fields • URL Rewriting • URL Rewriting is the approach in which a session (unique) identifier gets appended with each request URL so server can identify the user session. • Session Object • Session object is representation of a user session. User Session starts when a user opens a browser and sends the first request to server. Session object is available in all the request (in entire user session) so attributes stored in Http session in will be available in any servlet or in a jsp.