SlideShare a Scribd company logo
JSP
(JAVA SERVER PAGE)
• 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
• Java Server Pages are HTML pages embedded with
snippets of Java code.
• Four different elements are used in constructing
JSPs
– Scripting Elements
– Implicit Objects
– Directives
– Actions
Java Server Pages (JSP)
JSP Advantages Over a 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
JSP Advantages Over a Servlet…
• 2) Fast Development: No need to
recompile and redeploy
• -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.
JSP Advantages Over a Servlet…
• 3) Less code than Servlet
• -In JSP, we can use many tags such as
action tags, JSTL, custom tags, etc. that
reduces the code
• JSPs run in two phases
– Translation Phase
– Execution Phase
• In translation phase JSP
page is compiled into a
servlet
– called JSP Page
Implementation class
• In execution phase the
compliled JSP is
processed
Java Server Pages (JSP)
Architecture
Send
Response
Receive
Request
Load Servlet
Compile JSP
Servlet
Generate JSP
Servlet Source
Parse JSP
JSP Servlet
Current?
JSP Servlet
Loaded?
Generate
Response
Yes
No
No
Yes
HTTP Server
JSP Container
Page Compiler Servlet
JSP Page Servlet
JSP Scriptlet tag (Scripting elements)
The scripting elements provides the ability to
insert java code inside the jsp.
There are three types of scripting elements:
1. scriptlet tag
2. expression tag
3. declaration tag
JSP scriptlet tag
A scriptlet tag is used to execute java source
code in JSP.
• Syntax is as follows:
<% java source code %>
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);
%>
</form>
</body>
</html>
JSP expression tag
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 %>
<html>
<body>
<%= "welcome to jsp" %>
</body>
</html>
index.jsp
<html>
<body>
<form action="welcome.jsp">
<input type="text" name="uname"><br/>
<input type="submit" value="go">
</form>
</body>
</html>
welcome.jsp
<html>
<body>
<%= "Welcome "+request.getParameter("uname") %>
</body>
</html>
JSP Declaration Tag
 The JSP declaration tag is used to declare fields and
methods.
 The code written inside the jsp declaration tag is placed
outside the service() method of auto generated servlet.
Syntax of JSP declaration tag
• <%! field or method declaration %>
<html>
<body>
<%! int data=50; %>
<%= "Value of the variable is:"+data %>
</body>
</html>
Example of JSP declaration tag that declares method
<html>
<body>
<%!
int cube(int n){
return n*n*n*;
}
%>
<%= "Cube of 3 is:"+cube(3) %>
</body>
</html>

More Related Content

PPTX
Wt unit 4
PPTX
Java Server Pages
PPTX
Web programming-Introduction to JSP.pptx
PPTX
PPTX
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
PPT
JSP 1.pptdfdfdfdsfdsfdsfdsfdsgdgdgdgdgdd
PPTX
Jsp Introduction Tutorial
Wt unit 4
Java Server Pages
Web programming-Introduction to JSP.pptx
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
JSP 1.pptdfdfdfdsfdsfdsfdsfdsgdgdgdgdgdd
Jsp Introduction Tutorial

Similar to jsp elements java server tag with jsp elements .pptx (20)

PDF
Enterprise java unit-3_chapter-1-jsp
PPTX
Module 3.pptx.............................
PPTX
presentation on online movie ticket booking
PPT
Jsp abes new
PPTX
JavaScript, often abbreviated as JS, is a programming language and core techn...
PDF
PPTX
JSP - Java Server Page
PPTX
Introduction to JSP.pptx
PPTX
JSP APP DEVLOPMENT.pptx Related to Android App Development
PPTX
Core web application development
PPTX
JSP.pptx
PPTX
java server pages directives and processing
PPTX
JAVA SERVER PAGES
PPTX
Jsp session 1
PDF
20jsp
PPTX
WT Unit-Vuufvmjn dissimilating Dunkirk k
PPTX
Jsp basic
PPT
JSP Part 1
PPTX
JSP overview
Enterprise java unit-3_chapter-1-jsp
Module 3.pptx.............................
presentation on online movie ticket booking
Jsp abes new
JavaScript, often abbreviated as JS, is a programming language and core techn...
JSP - Java Server Page
Introduction to JSP.pptx
JSP APP DEVLOPMENT.pptx Related to Android App Development
Core web application development
JSP.pptx
java server pages directives and processing
JAVA SERVER PAGES
Jsp session 1
20jsp
WT Unit-Vuufvmjn dissimilating Dunkirk k
Jsp basic
JSP Part 1
JSP overview
Ad

More from yvtinsane (8)

PPT
vertopal.com_The-Power-of-Effective-Communication-in-Business-Growth-2.ppt
PPTX
FAI - Unit 4 - Logic and Knowledges.pptx
PPTX
FAI UNIT 3Search using games important.pptx
PPT
Network Models computer networks important.ppt
PPTX
IMPORTANT SESSION TRACKING TECHNIQUES.pptx
PPTX
JSP Directives IMPLICIT ACTIONS and HACKING.pptx
PPTX
Lower bound theory Np hard & Np completeness
PPTX
daa18d8d-d333-4398-94dd-a46802d88d79.pptx
vertopal.com_The-Power-of-Effective-Communication-in-Business-Growth-2.ppt
FAI - Unit 4 - Logic and Knowledges.pptx
FAI UNIT 3Search using games important.pptx
Network Models computer networks important.ppt
IMPORTANT SESSION TRACKING TECHNIQUES.pptx
JSP Directives IMPLICIT ACTIONS and HACKING.pptx
Lower bound theory Np hard & Np completeness
daa18d8d-d333-4398-94dd-a46802d88d79.pptx
Ad

Recently uploaded (20)

PPTX
Welding lecture in detail for understanding
PPTX
UNIT 4 Total Quality Management .pptx
PDF
Well-logging-methods_new................
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPT
Project quality management in manufacturing
PPTX
web development for engineering and engineering
PPTX
Sustainable Sites - Green Building Construction
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PDF
Digital Logic Computer Design lecture notes
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
CH1 Production IntroductoryConcepts.pptx
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
PPT on Performance Review to get promotions
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Welding lecture in detail for understanding
UNIT 4 Total Quality Management .pptx
Well-logging-methods_new................
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Operating System & Kernel Study Guide-1 - converted.pdf
Project quality management in manufacturing
web development for engineering and engineering
Sustainable Sites - Green Building Construction
Foundation to blockchain - A guide to Blockchain Tech
Embodied AI: Ushering in the Next Era of Intelligent Systems
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Digital Logic Computer Design lecture notes
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
CH1 Production IntroductoryConcepts.pptx
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPT on Performance Review to get promotions
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk

jsp elements java server tag with jsp elements .pptx

  • 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 • Java Server Pages are HTML pages embedded with snippets of Java code. • Four different elements are used in constructing JSPs – Scripting Elements – Implicit Objects – Directives – Actions Java Server Pages (JSP)
  • 3. JSP Advantages Over a 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
  • 4. JSP Advantages Over a Servlet… • 2) Fast Development: No need to recompile and redeploy • -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.
  • 5. JSP Advantages Over a Servlet… • 3) Less code than Servlet • -In JSP, we can use many tags such as action tags, JSTL, custom tags, etc. that reduces the code
  • 6. • JSPs run in two phases – Translation Phase – Execution Phase • In translation phase JSP page is compiled into a servlet – called JSP Page Implementation class • In execution phase the compliled JSP is processed Java Server Pages (JSP) Architecture Send Response Receive Request Load Servlet Compile JSP Servlet Generate JSP Servlet Source Parse JSP JSP Servlet Current? JSP Servlet Loaded? Generate Response Yes No No Yes HTTP Server JSP Container Page Compiler Servlet JSP Page Servlet
  • 7. JSP Scriptlet tag (Scripting elements) The scripting elements provides the ability to insert java code inside the jsp. There are three types of scripting elements: 1. scriptlet tag 2. expression tag 3. declaration tag
  • 8. JSP scriptlet tag A scriptlet tag is used to execute java source code in JSP. • Syntax is as follows: <% java source code %>
  • 9. index.html <html> <body> <form action="welcome.jsp"> <input type="text" name="uname"> <input type="submit" value="go"><br/> </form> </body> </html>
  • 11. JSP expression tag 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 %> <html> <body> <%= "welcome to jsp" %> </body> </html>
  • 12. index.jsp <html> <body> <form action="welcome.jsp"> <input type="text" name="uname"><br/> <input type="submit" value="go"> </form> </body> </html>
  • 14. JSP Declaration Tag  The JSP declaration tag is used to declare fields and methods.  The code written inside the jsp declaration tag is placed outside the service() method of auto generated servlet. Syntax of JSP declaration tag • <%! field or method declaration %> <html> <body> <%! int data=50; %> <%= "Value of the variable is:"+data %> </body> </html>
  • 15. Example of JSP declaration tag that declares method <html> <body> <%! int cube(int n){ return n*n*n*; } %> <%= "Cube of 3 is:"+cube(3) %> </body> </html>

Editor's Notes

  • #2: Prevention: locks at doors, window bars, walls round the property Detection: stolen items are missing, burglar alarms, closed circuit TV Reaction: call the police, replace stolen items, make an insurance claim … Prevention: encrypt your orders, rely on the merchant to perform checks on the caller, don’t use the Internet (?) … Detection: an unauthorized transaction appears on your credit card statement Reaction: complain, ask for a new card number, etc.
  • #6: Prevention: locks at doors, window bars, walls round the property Detection: stolen items are missing, burglar alarms, closed circuit TV Reaction: call the police, replace stolen items, make an insurance claim … Prevention: encrypt your orders, rely on the merchant to perform checks on the caller, don’t use the Internet (?) … Detection: an unauthorized transaction appears on your credit card statement Reaction: complain, ask for a new card number, etc.