SlideShare a Scribd company logo
P R E S E N T I N G B Y:
R I T I K T H A K U R , S A N TO S H R AT H O R E A N D
V I V E K PA N D I T
PRESENTING TO:
ASST. PROF. K.K. YADAV
AND BCA 5TH ‘B’
IntroductiontoJSPScriptingElements
JSP scriptingenablesonetoadd JAVAcodeintoJSP (Java server pages).TheJAVA codecanbe
insertedintothesepageswiththehelpofscripttags. JAVAcodecanbewrittenwithinthese
scriptingtags.TheserverwilldeterminetheJAVAcodeusingscripttagsas anindicatoratthestart
andendofcode.Thesescriptingtagsare calledscriptingelements.We willlearnmore aboutthe
functioninganduseofthesescriptingelementsinthistopicwiththehelpofexamples.
TypesofJSPScriptingElements
Scripting Element Example
Comment <%-- comment --%>
Directive <%@ directive %>
Declaration <%! declarations %>
Scriptlet <% scriplets %>
Expression <%= expression %>
There are five different types of scripting
elements
JSP Comment
JSP Comment is used when you are creating a JSP page and
want to put in comments about what you are doing. JSP
comments are only seen in the JSP page. These comments
are not included in servlet source code during translation
phase, nor they appear in the HTTP response. Syntax of JSP
comment is as follows :
<%-- JSP comment --%>
Simple Example of JSP Comment
<html>
<head>
<title>My First JSP Page</title>
</head>
<%
int count = 0;
%>
<body>
<%-- Code to show page count --%>
Page Count is <% out.println(++count); %>
</body>
</html>
JSP Scriptlet Tag
Scriptlet Tag allows you to write java code inside
JSP page.
Scriptlet tag implements the _jspService method
functionality by writing script/java code.
Syntax of Scriptlet Tag is as follows :
<% JAVA CODE %>
JSP: Example of Scriptlet
<html>
<head>
<title>My First JSP Page</title>
</head>
<%
int count = 0;
%>
<body>
Page Count is
<%
out.println(++count);
%>
</body>
</html>
In this example, we will show number of page visit.
JSP Declaration Tag
We know that at the end a JSP page is translated into Servlet
class. So when we declare a variable or method in JSP
inside Declaration Tag, it means the declaration is made
inside the Servlet class but outside the service(or any other)
method. You can declare static member, instance variable and
methods inside Declaration Tag. Syntax of Declaration Tag :
<%! declaration %>
Example of Declaration Tag
<html>
<head>
<title>My First JSP Page</title>
</head>
<%! int count = 0; %>
<body>
Page Count is: <% out.println(++count); %>
</body>
</html>
JSP Directive Tag
Directive Tag gives special instruction to Web Container at the time of page translation.
Directive tags are of three types: page, include and taglib.
Directive Description
<%@ page ... %> defines page dependent properties such as
language, session, errorPage etc.
<%@ include ... %> defines file to be included.
<%@ taglib ... %> declares tag library used in the page
Page Directive Tag
The Page directive defines a number of page dependent properties
which communicates with the Web Container at the time of translation.
Basic syntax of using the page directive is <%@ page attribute="value"
%> where attributes can be one of the following :
•import attribute
•language attribute
•extends attribute
•session attribute
•isThreadSafe attribute
•isErrorPage attribute
•errorPage attribute
•contentType attribute
•autoFlush attribute
•buffer attribute
JSP Expression Tag
Expression Tag is used to print out java language expression that is put between the
tags. An expression tag can hold any java language expression that can be used as an
argument to the out.print() method. Syntax of Expression Tag
<%= Java Expression %>
When the Container sees this
<%= (2*5) %>
It turns it into this:
out.print((2*5));
Note: Never end an expression with semicolon inside Expression Tag. Like this:
<%= (2*5); %>
Example of Expression Tag
<html>
<head>
<title>My First JSP Page</title>
</head>
<% int count = 0; %>
<body>
Page Count is <%= ++count %>
</body>
</html>
Java ppt

More Related Content

PPTX
basics of php
PPTX
JSP Directives
PPTX
Session 3 Java Script
PPTX
Java script functions
PPT
Processing XML with Java
PPT
Rich faces
PPT
Jsp 02(jsp directives)2003
PPT
Jicc teaching rails
basics of php
JSP Directives
Session 3 Java Script
Java script functions
Processing XML with Java
Rich faces
Jsp 02(jsp directives)2003
Jicc teaching rails

What's hot (13)

PDF
Java script tutorial
PPT
Unified Expression Language
PDF
Effective PHP. Part 6
PPTX
Jsp elements
PPTX
Java script Session No 1
PPTX
RESTful Web Development with CakePHP
PPTX
Servlet and jsp interview questions
PPTX
Designing CakePHP plugins for consuming APIs
PPT
Java Server Faces (JSF) - advanced
PPTX
Lecture6
PPT
Jsp Slides
PPT
Jsp intro
PDF
Effective PHP. Part 3
Java script tutorial
Unified Expression Language
Effective PHP. Part 6
Jsp elements
Java script Session No 1
RESTful Web Development with CakePHP
Servlet and jsp interview questions
Designing CakePHP plugins for consuming APIs
Java Server Faces (JSF) - advanced
Lecture6
Jsp Slides
Jsp intro
Effective PHP. Part 3
Ad

Similar to Java ppt (20)

PPTX
PPTX
Introduction - Java Server Programming (JSP)
PPT
Jsp sasidhar
PPTX
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
PPTX
JSP AND XML USING JAVA WITH GET AND POST METHODS
PPTX
JSP.pptx
PPTX
Java Server Pages
PPTX
Web programming-Introduction to JSP.pptx
PPS
Jsp element
PPT
Java serverpages
PPTX
SCWCD : Java server pages CHAP : 9
PPTX
JSP- JAVA SERVER PAGES
PPSX
JSP - Part 1
PPTX
Session 36 - JSP - Part 1
PDF
Java Web Programming [4/9] : JSP Basic
PDF
Lecture 4: JavaServer Pages (JSP) & Expression Language (EL)
PDF
PPTX
JSP - Java Server Page
Introduction - Java Server Programming (JSP)
Jsp sasidhar
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
JSP AND XML USING JAVA WITH GET AND POST METHODS
JSP.pptx
Java Server Pages
Web programming-Introduction to JSP.pptx
Jsp element
Java serverpages
SCWCD : Java server pages CHAP : 9
JSP- JAVA SERVER PAGES
JSP - Part 1
Session 36 - JSP - Part 1
Java Web Programming [4/9] : JSP Basic
Lecture 4: JavaServer Pages (JSP) & Expression Language (EL)
JSP - Java Server Page
Ad

Recently uploaded (20)

PPTX
microtomy kkk. presenting to cryst in gl
PPT
2- CELL INJURY L1 Medical (2) gggggggggg
PPTX
chapter 3_bem.pptxKLJLKJLKJLKJKJKLJKJKJKHJH
PPTX
Definition and Relation of Food Science( Lecture1).pptx
DOC
field study for teachers graduating samplr
PPT
Gsisgdkddkvdgjsjdvdbdbdbdghjkhgcvvkkfcxxfg
PDF
APNCET2025RESULT Result Result 2025 2025
PPTX
Your Guide to a Winning Interview Aug 2025.
PPTX
E-Commerce____Intermediate_Presentation.pptx
PPTX
Principles of Inheritance and variation class 12.pptx
PPTX
Sports and Dance -lesson 3 powerpoint presentation
PPTX
FINAL PPT.pptx cfyufuyfuyuy8ioyoiuvy ituyc utdfm v
PDF
esg-supply-chain-webinar-nov2018hkhkkh.pdf
PPTX
PE3-WEEK-3sdsadsadasdadadwadwdsdddddd.pptx
PPTX
Nervous_System_Drugs_PPT.pptxXXXXXXXXXXXXXXXXX
PPTX
PMP (Project Management Professional) course prepares individuals
PPTX
Cerebral_Palsy_Detailed_Presentation.pptx
PPTX
Autonomic_Nervous_SystemM_Drugs_PPT.pptx
PPT
BCH3201 (Enzymes and biocatalysis)-JEB (1).ppt
PPTX
Job-opportunities lecture about it skills
microtomy kkk. presenting to cryst in gl
2- CELL INJURY L1 Medical (2) gggggggggg
chapter 3_bem.pptxKLJLKJLKJLKJKJKLJKJKJKHJH
Definition and Relation of Food Science( Lecture1).pptx
field study for teachers graduating samplr
Gsisgdkddkvdgjsjdvdbdbdbdghjkhgcvvkkfcxxfg
APNCET2025RESULT Result Result 2025 2025
Your Guide to a Winning Interview Aug 2025.
E-Commerce____Intermediate_Presentation.pptx
Principles of Inheritance and variation class 12.pptx
Sports and Dance -lesson 3 powerpoint presentation
FINAL PPT.pptx cfyufuyfuyuy8ioyoiuvy ituyc utdfm v
esg-supply-chain-webinar-nov2018hkhkkh.pdf
PE3-WEEK-3sdsadsadasdadadwadwdsdddddd.pptx
Nervous_System_Drugs_PPT.pptxXXXXXXXXXXXXXXXXX
PMP (Project Management Professional) course prepares individuals
Cerebral_Palsy_Detailed_Presentation.pptx
Autonomic_Nervous_SystemM_Drugs_PPT.pptx
BCH3201 (Enzymes and biocatalysis)-JEB (1).ppt
Job-opportunities lecture about it skills

Java ppt

  • 1. P R E S E N T I N G B Y: R I T I K T H A K U R , S A N TO S H R AT H O R E A N D V I V E K PA N D I T PRESENTING TO: ASST. PROF. K.K. YADAV AND BCA 5TH ‘B’
  • 2. IntroductiontoJSPScriptingElements JSP scriptingenablesonetoadd JAVAcodeintoJSP (Java server pages).TheJAVA codecanbe insertedintothesepageswiththehelpofscripttags. JAVAcodecanbewrittenwithinthese scriptingtags.TheserverwilldeterminetheJAVAcodeusingscripttagsas anindicatoratthestart andendofcode.Thesescriptingtagsare calledscriptingelements.We willlearnmore aboutthe functioninganduseofthesescriptingelementsinthistopicwiththehelpofexamples.
  • 3. TypesofJSPScriptingElements Scripting Element Example Comment <%-- comment --%> Directive <%@ directive %> Declaration <%! declarations %> Scriptlet <% scriplets %> Expression <%= expression %> There are five different types of scripting elements
  • 4. JSP Comment JSP Comment is used when you are creating a JSP page and want to put in comments about what you are doing. JSP comments are only seen in the JSP page. These comments are not included in servlet source code during translation phase, nor they appear in the HTTP response. Syntax of JSP comment is as follows : <%-- JSP comment --%>
  • 5. Simple Example of JSP Comment <html> <head> <title>My First JSP Page</title> </head> <% int count = 0; %> <body> <%-- Code to show page count --%> Page Count is <% out.println(++count); %> </body> </html>
  • 6. JSP Scriptlet Tag Scriptlet Tag allows you to write java code inside JSP page. Scriptlet tag implements the _jspService method functionality by writing script/java code. Syntax of Scriptlet Tag is as follows : <% JAVA CODE %>
  • 7. JSP: Example of Scriptlet <html> <head> <title>My First JSP Page</title> </head> <% int count = 0; %> <body> Page Count is <% out.println(++count); %> </body> </html> In this example, we will show number of page visit.
  • 8. JSP Declaration Tag We know that at the end a JSP page is translated into Servlet class. So when we declare a variable or method in JSP inside Declaration Tag, it means the declaration is made inside the Servlet class but outside the service(or any other) method. You can declare static member, instance variable and methods inside Declaration Tag. Syntax of Declaration Tag : <%! declaration %>
  • 9. Example of Declaration Tag <html> <head> <title>My First JSP Page</title> </head> <%! int count = 0; %> <body> Page Count is: <% out.println(++count); %> </body> </html>
  • 10. JSP Directive Tag Directive Tag gives special instruction to Web Container at the time of page translation. Directive tags are of three types: page, include and taglib. Directive Description <%@ page ... %> defines page dependent properties such as language, session, errorPage etc. <%@ include ... %> defines file to be included. <%@ taglib ... %> declares tag library used in the page
  • 11. Page Directive Tag The Page directive defines a number of page dependent properties which communicates with the Web Container at the time of translation. Basic syntax of using the page directive is <%@ page attribute="value" %> where attributes can be one of the following : •import attribute •language attribute •extends attribute •session attribute •isThreadSafe attribute •isErrorPage attribute •errorPage attribute •contentType attribute •autoFlush attribute •buffer attribute
  • 12. JSP Expression Tag Expression Tag is used to print out java language expression that is put between the tags. An expression tag can hold any java language expression that can be used as an argument to the out.print() method. Syntax of Expression Tag <%= Java Expression %> When the Container sees this <%= (2*5) %> It turns it into this: out.print((2*5)); Note: Never end an expression with semicolon inside Expression Tag. Like this: <%= (2*5); %>
  • 13. Example of Expression Tag <html> <head> <title>My First JSP Page</title> </head> <% int count = 0; %> <body> Page Count is <%= ++count %> </body> </html>