SlideShare a Scribd company logo
1 of 20
Download to read offline
JSP
JAVA SERVER
PAGES
B Y P R I YA G OYA L
DYNAMIC WEB PAGES
• dynamic Web pages can display different content from the same source code.
• Dynamic Web pages are capable of producing different content for different
visitors from the same source code file.The website can display different
content based on what operating system or browser the visitor is using,
whether she is using a PC or a mobile device, or even the source that referred
the visitor.
• A dynamicWeb page is not necessarily better than a static Web page.The two
simply serve different purposes.
DIFFERENCE
BETWEEN
ASP AND JSP
INTRODUCTION TO JSP
• Java Server Pages allow special tags and Java code to be embedded in HTML files. These
tags and code are processed by the Web server to dynamically produce a standard HTML
page for the browser.
• Allows fast development and testing.
• JSPs combine static markup (HTML, XML) with special dynamic scripting tags. May also
produce XML documents, instead of HTML.
• A JSP page has the extension .jsp; this signals to the web server that the JSP engine will
process elements on this page.
•
4
JAVA SERVER PAGES
• JSP technology is an extension/wrapper over the Java servlet technology.
(Servlets are pure Java programs.They introduce dynamism into web pages by using
programmatic content.)
• JSP pages are easier to maintain then a Servlet. JSP pages are opposite of Servlets. Servlet
adds HTML code inside Java code while JSP adds Java code inside HTML. Everything a Servlet
can do, a JSP page can also do it.
• Two major components of JSP:
– Static content: provided by HTML or XML
– Dynamic content: generated by JSP tags and scriplets written in Java language to
encapsulate the application logic.
ADVANTAGE OF JSP
• Easy to maintain
• High Performance and Scalability.
• JSP is built on Java technology, so it is platform independent.
DEVELOPMENT OF JSP
• Java Server Pages were developed as a response to Microsoft’s Active Server Pages (ASP). The
main differences are that ASP only runs on Microsoft IIS and PersonalWeb Servers, and JSP has
user-defined tags.
• Development dates: (Note that JSP is built on top of Servlets)
– Servlet 2.1 Jan. 99
– JSP 1.0 June 99
– Source code released to Apache to developTomcat server November 99
– Servlet 2.2 and JSP 1.1 (J2EE1.2) December 99
7
HOW TO PREPARE AND RUN THE
EXAMPLES?
• Simple JSPs can be typed into .jsp type files using editor.
• Create a directory called JSPExamples in the public_html directory of J2EE. Store the
example JSPs here.
• Start the J2EE server.
• Run the JSP from your browser using the command:
• http://localhost:8000/JSPExamples/xyz.jsp
• For complex examples with actions and beans you will have to create web component
(WAR).
JAVA SERVER PAGES (JSP)
Client’s
Computer
Server
1.Browser requests HTML
7. Server sends HTML
back to browser
servlet
servlet
class 5.The servlet
runs and
generates
HTML
Java Engine
6. Java Engine sends HTML to server
2. Server sends requests to Java Engine
3. If needed, the Java Engine
reads the .jsp file
4.The JSP is turned into a
servlet, compiled, and loaded
Bean
Servlets are pure Java programs.They introduce dynamism into web pages by using programmatic content.
JSP TAGS
• Declaration: variable declaration
<%! int age = 56 %>
• Directive: ex: import classes
<%@ page import = “java.util.*” %>
• Scriplet: Java code
<% if password(“xyz”) {
%>
<H1>Welcome <H1>
• Expression: regular expression using variables and
constants
– <%= param[3]+4 %>
• Action: <jsp:usebean name =“cart”
class=“com.sun.java.Scart”
SCRIPTING
• JSP Scripting element are written inside <% %> tags.
• These code inside <% %> tags are processed by the JSP engine during translation of the JSP
page.
• Any other text in the JSP page is considered as HTML code or plain text.
SCRIPTING EXAMPLE
<HTML>
<HEAD><TITLE>Weather</TITLE></HEAD>
<BODY>
<H2>Today's weather</H2>
<% int count = 0; %>
Page Count is <% out.println(++count); %>
</BODY>
</HTML>
STANDARD TAG (ACTION ELEMENT)
• Standard actions are well known tags that affect the run time behavior of the JSP and the response
sent back to the client.
• JSP specification provides Standard(Action) tags for use within JSP pages.These tags are used to
remove or eliminate scriptlet code from JSP page because scriplet code are technically not
recommended nowadays.
• It's considered to be bad practice to put java code directly inside your JSP page.
• Standard tags begin with the jsp: prefix.There are many JSP Standard Action tag which are used to
perform some specific task.
The following are some JSP Standard ActionTag available:
JSP DIRECTIVE TAG
DirectiveTag gives special instruction toWeb Container at the time of page translation.
The jsp directives are messages that tells the web container how to translate a JSP page into the
corresponding servlet.
Directive tags are of three types: page, include and taglib.
PAGE DIRECTIVE
• The Page directive defines a number of page dependent properties which communicates with the Web Container at the time
of translation.
• The page directive is used to provide instructions to the container that pertain to the current JSP page. You may code page
directives anywhere in your JSP page. By convention, page directives are coded at the top of the JSP page.
• import attribute- defines the set of classes and packages that must be inported
• language attribute- defines scripting language to be used
• extends attribute- defines the class name of the superclass of the servlet class
• session attribute- whether the JSP page is participating in an HTTP session.
• isThreadSafe attribute- declares whether the JSP is thread-safe
• isErrorPage attribute-whether the current JSP Page represents another JSP's error page.
• errorPage attribute- indicates another JSP page that will handle all the run time exceptions thrown by current JSP page.
• contentType attribute- defines the MIME type for the JSP response.
• autoFlush attribute- defines whether the buffered output is flushed automatically
• buffer attribute- defines how buffering is handled by the implicit out object.
INCLUDE DIRECTIVE
• The include directive tells the Web Container to copy everything in the
included file and paste it into current JSP file. Syntax of include directive.
<%@ include file="filename.jsp" %>
The included file can be:
1. JSP file,
2. HTML file,
3. text file.
EXAMPLE OF INCLUDE DIRECTIVE
welcome.jsp
<html>
<head>
<title>Welcome Page</title>
</head>
<body>
<%@ include file="header.jsp" %>
Welcome, User
</body>
</html>
header.jsp
<html>
<body>
<img src="header.jpg" alt="This is Header
image" / >
</body>
</html>
REFRENCES
• [1] http://www.studytonight.com/jsp/creating-a-jsp-page.php
• [2] http://www.webstepbook.com/supplements-2ed/slides/ppt/22-jQuery1.pptx
• [3] http://www.studytonight.com/jsp/creating-a-jsp-page.php
THANK YOU

More Related Content

What's hot (20)

Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
JSP
JSPJSP
JSP
 
JSP Directives
JSP DirectivesJSP Directives
JSP Directives
 
Servlet and jsp interview questions
Servlet and jsp interview questionsServlet and jsp interview questions
Servlet and jsp interview questions
 
Jsp(java server pages)
Jsp(java server pages)Jsp(java server pages)
Jsp(java server pages)
 
JSP Scope variable And Data Sharing
JSP Scope variable And Data SharingJSP Scope variable And Data Sharing
JSP Scope variable And Data Sharing
 
Jsp Introduction Tutorial
Jsp Introduction TutorialJsp Introduction Tutorial
Jsp Introduction Tutorial
 
JSP Processing
JSP ProcessingJSP Processing
JSP Processing
 
Jsp lecture
Jsp lectureJsp lecture
Jsp lecture
 
INTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE AND JSP PROCESSING
INTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE  AND JSP PROCESSINGINTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE  AND JSP PROCESSING
INTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE AND JSP PROCESSING
 
Jsp sasidhar
Jsp sasidharJsp sasidhar
Jsp sasidhar
 
Jsp presentation
Jsp presentationJsp presentation
Jsp presentation
 
JSP - Java Server Page
JSP - Java Server PageJSP - Java Server Page
JSP - Java Server Page
 
Implicit objects advance Java
Implicit objects advance JavaImplicit objects advance Java
Implicit objects advance Java
 
Java server pages
Java server pagesJava server pages
Java server pages
 
Jsp slides
Jsp slidesJsp slides
Jsp slides
 
Jsp
JspJsp
Jsp
 
Implicit object.pptx
Implicit object.pptxImplicit object.pptx
Implicit object.pptx
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Jsp Slides
Jsp SlidesJsp Slides
Jsp Slides
 

Viewers also liked (10)

Java Script ppt
Java Script pptJava Script ppt
Java Script ppt
 
basics of css
basics of cssbasics of css
basics of css
 
Oraclesql
OraclesqlOraclesql
Oraclesql
 
Jsp with mvc
Jsp with mvcJsp with mvc
Jsp with mvc
 
J2EE and layered architecture
J2EE and layered architectureJ2EE and layered architecture
J2EE and layered architecture
 
J2EE Introduction
J2EE IntroductionJ2EE Introduction
J2EE Introduction
 
MVC ppt presentation
MVC ppt presentationMVC ppt presentation
MVC ppt presentation
 
Model View Controller (MVC)
Model View Controller (MVC)Model View Controller (MVC)
Model View Controller (MVC)
 
Mvc architecture
Mvc architectureMvc architecture
Mvc architecture
 
Cookies and sessions
Cookies and sessionsCookies and sessions
Cookies and sessions
 

Similar to Jsp

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 Ayes Chinmay
 
Enterprise java unit-3_chapter-1-jsp
Enterprise  java unit-3_chapter-1-jspEnterprise  java unit-3_chapter-1-jsp
Enterprise java unit-3_chapter-1-jspsandeep54552
 
JavaScript, often abbreviated as JS, is a programming language and core techn...
JavaScript, often abbreviated as JS, is a programming language and core techn...JavaScript, often abbreviated as JS, is a programming language and core techn...
JavaScript, often abbreviated as JS, is a programming language and core techn...MathivananP4
 
Core web application development
Core web application developmentCore web application development
Core web application developmentBahaa Farouk
 
Project First presentation about introduction to technologies to be used
Project First presentation about introduction to technologies to be usedProject First presentation about introduction to technologies to be used
Project First presentation about introduction to technologies to be usedarya krazydude
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server PagesRami Nayan
 
SCWCD : Java server pages CHAP : 9
SCWCD : Java server pages  CHAP : 9SCWCD : Java server pages  CHAP : 9
SCWCD : Java server pages CHAP : 9Ben Abdallah Helmi
 
11 page-directive
11 page-directive11 page-directive
11 page-directivesnopteck
 
Advance java session 9
Advance java session 9Advance java session 9
Advance java session 9Smita B Kumar
 
Servlets and jsp pages best practices
Servlets and jsp pages best practicesServlets and jsp pages best practices
Servlets and jsp pages best practicesejjavies
 
Java Web Programming [4/9] : JSP Basic
Java Web Programming [4/9] : JSP BasicJava Web Programming [4/9] : JSP Basic
Java Web Programming [4/9] : JSP BasicIMC Institute
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)slire
 

Similar to Jsp (20)

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
 
20jsp
20jsp20jsp
20jsp
 
Enterprise java unit-3_chapter-1-jsp
Enterprise  java unit-3_chapter-1-jspEnterprise  java unit-3_chapter-1-jsp
Enterprise java unit-3_chapter-1-jsp
 
JavaScript, often abbreviated as JS, is a programming language and core techn...
JavaScript, often abbreviated as JS, is a programming language and core techn...JavaScript, often abbreviated as JS, is a programming language and core techn...
JavaScript, often abbreviated as JS, is a programming language and core techn...
 
JSP.pptx
JSP.pptxJSP.pptx
JSP.pptx
 
Jsp basic
Jsp basicJsp basic
Jsp basic
 
Core web application development
Core web application developmentCore web application development
Core web application development
 
Jsp abes new
Jsp abes newJsp abes new
Jsp abes new
 
Project First presentation about introduction to technologies to be used
Project First presentation about introduction to technologies to be usedProject First presentation about introduction to technologies to be used
Project First presentation about introduction to technologies to be used
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Jsp in Servlet by Rj
Jsp in Servlet by RjJsp in Servlet by Rj
Jsp in Servlet by Rj
 
Wt unit 4
Wt unit 4Wt unit 4
Wt unit 4
 
JSP Part 1
JSP Part 1JSP Part 1
JSP Part 1
 
SCWCD : Java server pages CHAP : 9
SCWCD : Java server pages  CHAP : 9SCWCD : Java server pages  CHAP : 9
SCWCD : Java server pages CHAP : 9
 
Jsp
JspJsp
Jsp
 
11 page-directive
11 page-directive11 page-directive
11 page-directive
 
Advance java session 9
Advance java session 9Advance java session 9
Advance java session 9
 
Servlets and jsp pages best practices
Servlets and jsp pages best practicesServlets and jsp pages best practices
Servlets and jsp pages best practices
 
Java Web Programming [4/9] : JSP Basic
Java Web Programming [4/9] : JSP BasicJava Web Programming [4/9] : JSP Basic
Java Web Programming [4/9] : JSP Basic
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 

Recently uploaded

React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 

Recently uploaded (20)

React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 

Jsp

  • 1. JSP JAVA SERVER PAGES B Y P R I YA G OYA L
  • 2. DYNAMIC WEB PAGES • dynamic Web pages can display different content from the same source code. • Dynamic Web pages are capable of producing different content for different visitors from the same source code file.The website can display different content based on what operating system or browser the visitor is using, whether she is using a PC or a mobile device, or even the source that referred the visitor. • A dynamicWeb page is not necessarily better than a static Web page.The two simply serve different purposes.
  • 4. INTRODUCTION TO JSP • Java Server Pages allow special tags and Java code to be embedded in HTML files. These tags and code are processed by the Web server to dynamically produce a standard HTML page for the browser. • Allows fast development and testing. • JSPs combine static markup (HTML, XML) with special dynamic scripting tags. May also produce XML documents, instead of HTML. • A JSP page has the extension .jsp; this signals to the web server that the JSP engine will process elements on this page. • 4
  • 5. JAVA SERVER PAGES • JSP technology is an extension/wrapper over the Java servlet technology. (Servlets are pure Java programs.They introduce dynamism into web pages by using programmatic content.) • JSP pages are easier to maintain then a Servlet. JSP pages are opposite of Servlets. Servlet adds HTML code inside Java code while JSP adds Java code inside HTML. Everything a Servlet can do, a JSP page can also do it. • Two major components of JSP: – Static content: provided by HTML or XML – Dynamic content: generated by JSP tags and scriplets written in Java language to encapsulate the application logic.
  • 6. ADVANTAGE OF JSP • Easy to maintain • High Performance and Scalability. • JSP is built on Java technology, so it is platform independent.
  • 7. DEVELOPMENT OF JSP • Java Server Pages were developed as a response to Microsoft’s Active Server Pages (ASP). The main differences are that ASP only runs on Microsoft IIS and PersonalWeb Servers, and JSP has user-defined tags. • Development dates: (Note that JSP is built on top of Servlets) – Servlet 2.1 Jan. 99 – JSP 1.0 June 99 – Source code released to Apache to developTomcat server November 99 – Servlet 2.2 and JSP 1.1 (J2EE1.2) December 99 7
  • 8. HOW TO PREPARE AND RUN THE EXAMPLES? • Simple JSPs can be typed into .jsp type files using editor. • Create a directory called JSPExamples in the public_html directory of J2EE. Store the example JSPs here. • Start the J2EE server. • Run the JSP from your browser using the command: • http://localhost:8000/JSPExamples/xyz.jsp • For complex examples with actions and beans you will have to create web component (WAR).
  • 9. JAVA SERVER PAGES (JSP) Client’s Computer Server 1.Browser requests HTML 7. Server sends HTML back to browser servlet servlet class 5.The servlet runs and generates HTML Java Engine 6. Java Engine sends HTML to server 2. Server sends requests to Java Engine 3. If needed, the Java Engine reads the .jsp file 4.The JSP is turned into a servlet, compiled, and loaded Bean Servlets are pure Java programs.They introduce dynamism into web pages by using programmatic content.
  • 10. JSP TAGS • Declaration: variable declaration <%! int age = 56 %> • Directive: ex: import classes <%@ page import = “java.util.*” %> • Scriplet: Java code <% if password(“xyz”) { %> <H1>Welcome <H1> • Expression: regular expression using variables and constants – <%= param[3]+4 %> • Action: <jsp:usebean name =“cart” class=“com.sun.java.Scart”
  • 11. SCRIPTING • JSP Scripting element are written inside <% %> tags. • These code inside <% %> tags are processed by the JSP engine during translation of the JSP page. • Any other text in the JSP page is considered as HTML code or plain text.
  • 12. SCRIPTING EXAMPLE <HTML> <HEAD><TITLE>Weather</TITLE></HEAD> <BODY> <H2>Today's weather</H2> <% int count = 0; %> Page Count is <% out.println(++count); %> </BODY> </HTML>
  • 13. STANDARD TAG (ACTION ELEMENT) • Standard actions are well known tags that affect the run time behavior of the JSP and the response sent back to the client. • JSP specification provides Standard(Action) tags for use within JSP pages.These tags are used to remove or eliminate scriptlet code from JSP page because scriplet code are technically not recommended nowadays. • It's considered to be bad practice to put java code directly inside your JSP page. • Standard tags begin with the jsp: prefix.There are many JSP Standard Action tag which are used to perform some specific task.
  • 14. The following are some JSP Standard ActionTag available:
  • 15. JSP DIRECTIVE TAG DirectiveTag gives special instruction toWeb Container at the time of page translation. The jsp directives are messages that tells the web container how to translate a JSP page into the corresponding servlet. Directive tags are of three types: page, include and taglib.
  • 16. PAGE DIRECTIVE • The Page directive defines a number of page dependent properties which communicates with the Web Container at the time of translation. • The page directive is used to provide instructions to the container that pertain to the current JSP page. You may code page directives anywhere in your JSP page. By convention, page directives are coded at the top of the JSP page. • import attribute- defines the set of classes and packages that must be inported • language attribute- defines scripting language to be used • extends attribute- defines the class name of the superclass of the servlet class • session attribute- whether the JSP page is participating in an HTTP session. • isThreadSafe attribute- declares whether the JSP is thread-safe • isErrorPage attribute-whether the current JSP Page represents another JSP's error page. • errorPage attribute- indicates another JSP page that will handle all the run time exceptions thrown by current JSP page. • contentType attribute- defines the MIME type for the JSP response. • autoFlush attribute- defines whether the buffered output is flushed automatically • buffer attribute- defines how buffering is handled by the implicit out object.
  • 17. INCLUDE DIRECTIVE • The include directive tells the Web Container to copy everything in the included file and paste it into current JSP file. Syntax of include directive. <%@ include file="filename.jsp" %> The included file can be: 1. JSP file, 2. HTML file, 3. text file.
  • 18. EXAMPLE OF INCLUDE DIRECTIVE welcome.jsp <html> <head> <title>Welcome Page</title> </head> <body> <%@ include file="header.jsp" %> Welcome, User </body> </html> header.jsp <html> <body> <img src="header.jpg" alt="This is Header image" / > </body> </html>
  • 19. REFRENCES • [1] http://www.studytonight.com/jsp/creating-a-jsp-page.php • [2] http://www.webstepbook.com/supplements-2ed/slides/ppt/22-jQuery1.pptx • [3] http://www.studytonight.com/jsp/creating-a-jsp-page.php