SlideShare uma empresa Scribd logo
JSP Application Models 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Review 
 A JavaBean is a reusable software component that is manipulated in a 
builder tool. 
 get() and set() methods are used with the property for which the data 
has to be set. 
 The features of JavaBeans are methods, events, properties, 
introspection and serialization. 
 JavaBeans have four scopes; page, request, session and application. 
 JAR is a compressed file containing the Java classes. 
 Every JavaBean is a Java class, but every Java class may not be a 
JavaBean. 
 <jsp:useBean> tag is used for creating reference in any code. 
 The Bean tag provides the page a means to encapsulate business logic 
separately from the content presentation. 
 The key components of JavaMail APIs are session, message and 
transport. 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
JSP Application Models Overview 
 Consists of Java code, HTML codes, and JSP 
tags 
 Two approaches for building JSP 
applications are: 
 Model 1 
 Model 2 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Model 1 Architecture 
 Represents a page-centric design 
 Developed using scripting elements, custom tags, and a 
scripting language 
 Client request is directly processed by JSP page 
 JSP page accesses the database through JavaBeans to 
generate a response 
 Model 1 applications are difficult to modify 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Model 2 Architecture 
 Represents a controller design 
 Suitable for large and complex applications 
 Consists of a combination of servlets, JSP and JavaBeans 
 Based on Model-View-Controller (MVC) pattern 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Model 2 Architecture (cont.) 
 The MVC pattern includes: 
 Model – Represents the application object or data that serves 
multiple views 
 View – Represents the presentation component or the user 
interface component of the data model 
 Controller – Responds to the input in the user interface. The 
controller transmits the request, and selects a view for presenting 
data to the user. 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Implementing Model 2 Architecture 
 Requires controller servlet, request handler, page beans and JSP 
views 
 Controller servlet handles the incoming request, and forwards to the 
request handler for further processing 
 The handleRequest() method of the RequestHandler 
interface processes the request, and returns the URL of the JSP view 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
J2EE Framework 
 Provides enterprise services, such as transactions and security 
 Uses enterprise beans as a component 
 Enables low and high level data communication, design pattern, and a 
component model that enables to build reusable components 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
J2EE Framework - Components 
 Servlet – Consists of get() and post() methods, that are 
used for requesting data in dynamic Web applications 
 Session bean – Consist of temporary objects that enable to 
distribute and isolate the processing task. The two forms of 
shared data are: 
 Stateful 
 Stateless 
 Entity bean – Represents the data items, such as rows in a 
result set. The two forms of entity beans are: 
 Container managed persistence 
 Bean managed persistence 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
J2EE Framework – Components (cont.) 
 Java terminologies – Includes terminologies, such as Java 
Naming and Directory Interface (JNDI), Enterprise JavaBeans 
(EJB), servlets, JavaServer Pages (JSP), Extensible Markup 
Language (XML) and Remote Method Invocation (RMI) that are 
used in Web applications 
 Java Virtual Machine (JVM) – Provides a consistent execution 
platform for running Java codes 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
J2EE Framework - Benefits 
 Common application model – Enables to create distributed, 
reliable, scalable and secure Web applications 
 Generic infrastructure - Provides compatibility across vendors by 
introducing a standard Application Program Interface (API) 
 Easy deployment and execution - Simplifies the task of deploying 
and running the Web application 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
RequestDispatcher Interface 
 Forwards the request from a JSP page or a servlet to other resources 
 Other resources process the request and send a response to the client 
 The RequestDispatcher interface encapsulates the URL of a resource 
 Two methods of RequestDispatcher interface are: 
 Include() 
 Forward() 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
RequestDispatcher Interface Methods 
Methods Syntax Description 
include() 
<jsp:include 
page="localURL" 
flush = "true") 
Invokes one JSP page or 
servlet from another 
forward() <jsp:forward 
page="Nextpage. 
jsp"/> 
Forwards a request from 
one JSP page or servlet to 
another 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Includes page from 
specified URL 
Additional request 
parameters 
Transfers control 
to specified URL 
Additional request 
parameters 
Using Methods - Code Snippets 
<jsp:include page="localURL" flush="true "> 
<jsp:param name="parameterName1" value="parameterValue1"/> 
//code 
<jsp:param name="parameterName1" value="parameterValue1"/> 
</jsp:include> 
Using Include () 
<jsp:forward page="localURL "> 
<jsp:param name="parameterName1" value="parameterValue1"/> 
//code 
<jsp:param name="parameterNameN" value="parameterValueN "/> 
</jsp:forward> 
Using Forward () 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Exception Handling 
 Exceptions are errors that can occur in a JSP page 
 The JSP page traps and handles request time errors 
 Unhandled exceptions are forwarded to the error page 
 Syntax 
<%@ page errorPage=“errorpage.jsp” %> 
 Set the isErrorPage attribute of page directive to true, to 
make a JSP page an error handler 
 Syntax 
<%@ page isErrorPage=“true” %> 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Exception Handling - Cont… 
 Translation time - Occurs when the JSP source file is converted to 
servlets class file. The JSP engine handles translation time errors. 
 Request time - Occurs during the processing of the request. Request 
time errors are the runtime errors that throw exceptions. 
Makes JSP page an 
error handler 
Returns error 
message 
<html> 
<body> 
<%@ page isErrorPage="true" %> 
Detected Error: <br> 
<%= exception.getMessage() %> 
</body> 
</html> 
Code Snippet to create an error page 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Exception Handling - Cont… 
<%@ page errorPage="errorpage.jsp" %> 
<% 
if (request.getParameter("param ").equals("value ")) 
{ 
// code 
} 
//The test above will throw a NullPointerException if param is 
// not part of the query string. A better implementation is: 
if ("value".equals(request.getParameter("param "))) 
{ 
// code 
} 
%> 
Forwards the unhandled 
exception to 
errorpage.jsp 
Code Snippet to transfer control to the 
error page 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Summary 
 JSP technology enables the user to separate the presentation logic with the 
programming logic 
 The user can make JSP page easy to read and maintain, by embedding 
HTML or XML in the JSP page 
 Model 1 application is developed using scripting elements, custom tags, 
and a scripting language, such as JavaScript 
 JSP page directly processes the request, and sends response to the client in 
Model 1 architecture 
 The Model 2 applications are based on Model-View-Controller (MVC) 
pattern: 
 Model 
 View 
 Controller 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Summary – Cont… 
 J2EE framework provides ready to use enterprise services, such as 
transactions and security 
 The RequestDispatcher interface forwards the request from a JSP page or a 
servlet to other resources, such as HTML file, servlet, or a JSP page 
 The two methods in RequesDispatcher interface are: 
 include() 
 forward() 
 The unhandled exceptions are forwarded to the error handler file 
 The errors in JSP page includes: 
 Translation time 
 Request time 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Q & A 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3

Mais conteúdo relacionado

Mais procurados

jdbc
jdbcjdbc
J2EE Architecture Explained
J2EE  Architecture ExplainedJ2EE  Architecture Explained
J2EE Architecture Explained
Adarsh Kr Sinha
 
Jdbc
JdbcJdbc
Spring Framework -I
Spring Framework -ISpring Framework -I
Spring Framework -I
People Strategists
 
Java J2EE
Java J2EEJava J2EE
Java J2EE
Sandeep Rawat
 
J2ee
J2eeJ2ee
Types of Drivers in JDBC
Types of Drivers in JDBCTypes of Drivers in JDBC
Types of Drivers in JDBC
Hemant Sharma
 
Hibernate I
Hibernate IHibernate I
Hibernate I
People Strategists
 
J2ee seminar
J2ee seminarJ2ee seminar
J2ee seminar
Sahil Kukreja
 
Summer industrial trainingnew
Summer industrial trainingnewSummer industrial trainingnew
Summer industrial trainingnew
Vignesh Ramesh
 
J2EE Introduction
J2EE IntroductionJ2EE Introduction
J2EE Introduction
Patroklos Papapetrou (Pat)
 
Jsf+ejb 50
Jsf+ejb 50Jsf+ejb 50
Jsf+ejb 50
lullabyte
 
JSP Technology I
JSP Technology IJSP Technology I
JSP Technology I
People Strategists
 
Lab 5a) create a struts application
Lab 5a) create a struts applicationLab 5a) create a struts application
Lab 5a) create a struts application
techbed
 
Java ee introduction
Java ee introductionJava ee introduction
Java ee introduction
Moumie Soulemane
 
IRJET- Training and Placement Database Management System
IRJET- Training and Placement Database Management SystemIRJET- Training and Placement Database Management System
IRJET- Training and Placement Database Management System
IRJET Journal
 
Part 7 packaging and deployment
Part 7 packaging and deploymentPart 7 packaging and deployment
Part 7 packaging and deployment
techbed
 
A dynamic application using jboss
A dynamic application using jbossA dynamic application using jboss
A dynamic application using jboss
ijcax
 
9. java server faces
9. java server faces9. java server faces
9. java server faces
AnusAhmad
 

Mais procurados (19)

jdbc
jdbcjdbc
jdbc
 
J2EE Architecture Explained
J2EE  Architecture ExplainedJ2EE  Architecture Explained
J2EE Architecture Explained
 
Jdbc
JdbcJdbc
Jdbc
 
Spring Framework -I
Spring Framework -ISpring Framework -I
Spring Framework -I
 
Java J2EE
Java J2EEJava J2EE
Java J2EE
 
J2ee
J2eeJ2ee
J2ee
 
Types of Drivers in JDBC
Types of Drivers in JDBCTypes of Drivers in JDBC
Types of Drivers in JDBC
 
Hibernate I
Hibernate IHibernate I
Hibernate I
 
J2ee seminar
J2ee seminarJ2ee seminar
J2ee seminar
 
Summer industrial trainingnew
Summer industrial trainingnewSummer industrial trainingnew
Summer industrial trainingnew
 
J2EE Introduction
J2EE IntroductionJ2EE Introduction
J2EE Introduction
 
Jsf+ejb 50
Jsf+ejb 50Jsf+ejb 50
Jsf+ejb 50
 
JSP Technology I
JSP Technology IJSP Technology I
JSP Technology I
 
Lab 5a) create a struts application
Lab 5a) create a struts applicationLab 5a) create a struts application
Lab 5a) create a struts application
 
Java ee introduction
Java ee introductionJava ee introduction
Java ee introduction
 
IRJET- Training and Placement Database Management System
IRJET- Training and Placement Database Management SystemIRJET- Training and Placement Database Management System
IRJET- Training and Placement Database Management System
 
Part 7 packaging and deployment
Part 7 packaging and deploymentPart 7 packaging and deployment
Part 7 packaging and deployment
 
A dynamic application using jboss
A dynamic application using jbossA dynamic application using jboss
A dynamic application using jboss
 
9. java server faces
9. java server faces9. java server faces
9. java server faces
 

Semelhante a 1.jsp application models

3.java database connectivity
3.java database connectivity3.java database connectivity
3.java database connectivity
web360
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
tola99
 
IRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHPIRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHP
IRJET Journal
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET Presentation
Rasel Khan
 
Introduction to ejb and struts framework
Introduction to ejb and struts frameworkIntroduction to ejb and struts framework
Introduction to ejb and struts framework
s4al_com
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5
Tuna Tore
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892
Tuna Tore
 
Jsf2 overview
Jsf2 overviewJsf2 overview
Jsf2 overview
sohan1234
 
JavaEE6 my way
JavaEE6 my wayJavaEE6 my way
JavaEE6 my way
Nicola Pedot
 
Month 2 report
Month 2 reportMonth 2 report
Month 2 report
PRIYANKA FNU
 
Intorduction to struts
Intorduction to strutsIntorduction to struts
Intorduction to struts
Anup72
 
Struts notes
Struts notesStruts notes
Struts notes
dssreenath
 
Struts natraj - satya
Struts   natraj - satyaStruts   natraj - satya
Struts natraj - satya
Satya Johnny
 
Struts natraj - satya
Struts   natraj - satyaStruts   natraj - satya
Struts natraj - satya
Seshadri Pullaanagari
 
Struts 2 Overview
Struts 2 OverviewStruts 2 Overview
Struts 2 Overview
skill-guru
 
Mvc15 (1)
Mvc15 (1)Mvc15 (1)
Mvc15 (1)
sloumaallagui1
 
ASP, ASP.NET, JSP, COM/DCOM
ASP, ASP.NET, JSP, COM/DCOMASP, ASP.NET, JSP, COM/DCOM
ASP, ASP.NET, JSP, COM/DCOM
Aashish Jain
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2
divzi1913
 
Servlets and jsp pages best practices
Servlets and jsp pages best practicesServlets and jsp pages best practices
Servlets and jsp pages best practices
ejjavies
 
Java Server Faces (JSF) - Basics
Java Server Faces (JSF) - BasicsJava Server Faces (JSF) - Basics
Java Server Faces (JSF) - Basics
BG Java EE Course
 

Semelhante a 1.jsp application models (20)

3.java database connectivity
3.java database connectivity3.java database connectivity
3.java database connectivity
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
 
IRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHPIRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHP
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET Presentation
 
Introduction to ejb and struts framework
Introduction to ejb and struts frameworkIntroduction to ejb and struts framework
Introduction to ejb and struts framework
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892
 
Jsf2 overview
Jsf2 overviewJsf2 overview
Jsf2 overview
 
JavaEE6 my way
JavaEE6 my wayJavaEE6 my way
JavaEE6 my way
 
Month 2 report
Month 2 reportMonth 2 report
Month 2 report
 
Intorduction to struts
Intorduction to strutsIntorduction to struts
Intorduction to struts
 
Struts notes
Struts notesStruts notes
Struts notes
 
Struts natraj - satya
Struts   natraj - satyaStruts   natraj - satya
Struts natraj - satya
 
Struts natraj - satya
Struts   natraj - satyaStruts   natraj - satya
Struts natraj - satya
 
Struts 2 Overview
Struts 2 OverviewStruts 2 Overview
Struts 2 Overview
 
Mvc15 (1)
Mvc15 (1)Mvc15 (1)
Mvc15 (1)
 
ASP, ASP.NET, JSP, COM/DCOM
ASP, ASP.NET, JSP, COM/DCOMASP, ASP.NET, JSP, COM/DCOM
ASP, ASP.NET, JSP, COM/DCOM
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2
 
Servlets and jsp pages best practices
Servlets and jsp pages best practicesServlets and jsp pages best practices
Servlets and jsp pages best practices
 
Java Server Faces (JSF) - Basics
Java Server Faces (JSF) - BasicsJava Server Faces (JSF) - Basics
Java Server Faces (JSF) - Basics
 

Último

SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
GohKiangHock
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
TaghreedAltamimi
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
Quickdice ERP
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative AnalysisOdoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Envertis Software Solutions
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
dakas1
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
VALiNTRY360
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
mz5nrf0n
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
What next after learning python programming basics
What next after learning python programming basicsWhat next after learning python programming basics
What next after learning python programming basics
Rakesh Kumar R
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
Drona Infotech
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 

Último (20)

SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative AnalysisOdoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
What next after learning python programming basics
What next after learning python programming basicsWhat next after learning python programming basics
What next after learning python programming basics
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 

1.jsp application models

  • 1. JSP Application Models ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 2. Review  A JavaBean is a reusable software component that is manipulated in a builder tool.  get() and set() methods are used with the property for which the data has to be set.  The features of JavaBeans are methods, events, properties, introspection and serialization.  JavaBeans have four scopes; page, request, session and application.  JAR is a compressed file containing the Java classes.  Every JavaBean is a Java class, but every Java class may not be a JavaBean.  <jsp:useBean> tag is used for creating reference in any code.  The Bean tag provides the page a means to encapsulate business logic separately from the content presentation.  The key components of JavaMail APIs are session, message and transport. ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 3. JSP Application Models Overview  Consists of Java code, HTML codes, and JSP tags  Two approaches for building JSP applications are:  Model 1  Model 2 ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 4. Model 1 Architecture  Represents a page-centric design  Developed using scripting elements, custom tags, and a scripting language  Client request is directly processed by JSP page  JSP page accesses the database through JavaBeans to generate a response  Model 1 applications are difficult to modify ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 5. Model 2 Architecture  Represents a controller design  Suitable for large and complex applications  Consists of a combination of servlets, JSP and JavaBeans  Based on Model-View-Controller (MVC) pattern ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 6. Model 2 Architecture (cont.)  The MVC pattern includes:  Model – Represents the application object or data that serves multiple views  View – Represents the presentation component or the user interface component of the data model  Controller – Responds to the input in the user interface. The controller transmits the request, and selects a view for presenting data to the user. ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 7. Implementing Model 2 Architecture  Requires controller servlet, request handler, page beans and JSP views  Controller servlet handles the incoming request, and forwards to the request handler for further processing  The handleRequest() method of the RequestHandler interface processes the request, and returns the URL of the JSP view ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 8. J2EE Framework  Provides enterprise services, such as transactions and security  Uses enterprise beans as a component  Enables low and high level data communication, design pattern, and a component model that enables to build reusable components ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 9. J2EE Framework - Components  Servlet – Consists of get() and post() methods, that are used for requesting data in dynamic Web applications  Session bean – Consist of temporary objects that enable to distribute and isolate the processing task. The two forms of shared data are:  Stateful  Stateless  Entity bean – Represents the data items, such as rows in a result set. The two forms of entity beans are:  Container managed persistence  Bean managed persistence ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 10. J2EE Framework – Components (cont.)  Java terminologies – Includes terminologies, such as Java Naming and Directory Interface (JNDI), Enterprise JavaBeans (EJB), servlets, JavaServer Pages (JSP), Extensible Markup Language (XML) and Remote Method Invocation (RMI) that are used in Web applications  Java Virtual Machine (JVM) – Provides a consistent execution platform for running Java codes ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 11. J2EE Framework - Benefits  Common application model – Enables to create distributed, reliable, scalable and secure Web applications  Generic infrastructure - Provides compatibility across vendors by introducing a standard Application Program Interface (API)  Easy deployment and execution - Simplifies the task of deploying and running the Web application ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 12. RequestDispatcher Interface  Forwards the request from a JSP page or a servlet to other resources  Other resources process the request and send a response to the client  The RequestDispatcher interface encapsulates the URL of a resource  Two methods of RequestDispatcher interface are:  Include()  Forward() ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 13. RequestDispatcher Interface Methods Methods Syntax Description include() <jsp:include page="localURL" flush = "true") Invokes one JSP page or servlet from another forward() <jsp:forward page="Nextpage. jsp"/> Forwards a request from one JSP page or servlet to another ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 14. Includes page from specified URL Additional request parameters Transfers control to specified URL Additional request parameters Using Methods - Code Snippets <jsp:include page="localURL" flush="true "> <jsp:param name="parameterName1" value="parameterValue1"/> //code <jsp:param name="parameterName1" value="parameterValue1"/> </jsp:include> Using Include () <jsp:forward page="localURL "> <jsp:param name="parameterName1" value="parameterValue1"/> //code <jsp:param name="parameterNameN" value="parameterValueN "/> </jsp:forward> Using Forward () ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 15. Exception Handling  Exceptions are errors that can occur in a JSP page  The JSP page traps and handles request time errors  Unhandled exceptions are forwarded to the error page  Syntax <%@ page errorPage=“errorpage.jsp” %>  Set the isErrorPage attribute of page directive to true, to make a JSP page an error handler  Syntax <%@ page isErrorPage=“true” %> ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 16. Exception Handling - Cont…  Translation time - Occurs when the JSP source file is converted to servlets class file. The JSP engine handles translation time errors.  Request time - Occurs during the processing of the request. Request time errors are the runtime errors that throw exceptions. Makes JSP page an error handler Returns error message <html> <body> <%@ page isErrorPage="true" %> Detected Error: <br> <%= exception.getMessage() %> </body> </html> Code Snippet to create an error page ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 17. Exception Handling - Cont… <%@ page errorPage="errorpage.jsp" %> <% if (request.getParameter("param ").equals("value ")) { // code } //The test above will throw a NullPointerException if param is // not part of the query string. A better implementation is: if ("value".equals(request.getParameter("param "))) { // code } %> Forwards the unhandled exception to errorpage.jsp Code Snippet to transfer control to the error page ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 18. Summary  JSP technology enables the user to separate the presentation logic with the programming logic  The user can make JSP page easy to read and maintain, by embedding HTML or XML in the JSP page  Model 1 application is developed using scripting elements, custom tags, and a scripting language, such as JavaScript  JSP page directly processes the request, and sends response to the client in Model 1 architecture  The Model 2 applications are based on Model-View-Controller (MVC) pattern:  Model  View  Controller ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 19. Summary – Cont…  J2EE framework provides ready to use enterprise services, such as transactions and security  The RequestDispatcher interface forwards the request from a JSP page or a servlet to other resources, such as HTML file, servlet, or a JSP page  The two methods in RequesDispatcher interface are:  include()  forward()  The unhandled exceptions are forwarded to the error handler file  The errors in JSP page includes:  Translation time  Request time ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 20. Q & A ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3