SlideShare a Scribd company logo
1 of 17
Java/J2EE Programming Training
Request Dispatcher
Page 2Classification: Restricted
Agenda
• Understand Request Dispatcher
• JSP
Page 3Classification: Restricted
Page 4Classification: Restricted
num1
num2
Num1= 10
Num2= 20
sum = 30
response
Public void doGet(HttpServletRequest req,
HttpServletResponse res)
{
String num= req.getParameter(“num1”);
String num2 = req.getParameter(“num2”);
int n1 = Integer.parseInt(“num1”);
int n2= Integer.parseInt(“num2”);
Integer sum= n1 +n2;
req.setAttribute(“sum”,sum);
}
Page 6Classification: Restricted
FactorialServlet
num1
num2
Rd.forward(req, resp)
Num1= 10
Num2= 20
Sum = 30
respons
e
Public void doGet(HttpServletRequest
req, HttpServletResponse res)
{
request.setAttribute(“sum”, sum);
RequestDispatcher rd;
rd =
req.getRequestDispatcher(“fact”);
rd.forward(req, res)
}
Page 8Classification: Restricted
FactorialServlet
num1
num2
Rd.forward
(req, resp)
Public void
doGet(HttpServletRequest req,
HttpServletResponse res)
{ request.setAttribute(“sum”,
sum);
RequestDispatcher rd;
Rd =
req.getRequestDispatcher(“fa
ct”);
rd.forward(req, res)
}
Num1= 10
Num2= 20
Sum = 30
Response
“sum = “ +
sum
Public void
doGet(HttpServletRequest req,
HttpServletResponse res)
{
String sum =
req.getAttribute(“sum”).toString();
out.println( “sum = “ + sum )
}
Page 9Classification: Restricted
FactorialServlet
num1
num2
Rd.forward
(req, resp)
Public void
doGet(HttpServletRequest req,
HttpServletResponse res)
{ request.setAttribute(“sum”,
sum);
RequestDispatcher rd;
Rd =
req.getRequestDispatcher(“fact”
);
rd.forward(req, res)
}
Num1= 10
Num2= 20
Sum = 30
Response
“sum = “ +
sum
Public void
doGet(HttpServletRequest req,
HttpServletResponse res)
{
String sum =
req.getAttribute(“sum”).toString();
out.println( “sum = “ + sum )
}
Page 10Classification: Restricted
username
password
valid
Home.jsp Login.jsp
Page 11Classification: Restricted
public void doGet(HttpServletRequest req,
HttpServletResponse res)
{
if( valid)
{
RequestDispatcher rd =
req.getRequestDispatcher(“Home.jsp”)
rd.forward(req, res);
}
else
{
req.setAttribute(“error”, “username or
password is invalid”);
RequestDispatcher rd
=req.getRequestDispatcher(“Login.jsp”);
rd.forward(req, res);
}
}
login
Page 12Classification: Restricted
public void doGet(HttpServletRequest req,
HttpServletResponse res)
{
if( valid)
{
RequestDispatcher rd =
req.getRequestDispatcher(“Home.jsp”)
rd.forward(req, res);
}
else
{
req.setAttribute(“error”, “username or password
is invalid”);
RequestDispatcher rd
=req.getRequestDispatcher(“Login.jsp”);
rd.forward(req, res);
}
}
Home About
username/pwd
invalid
login
Page 13Classification: Restricted
public void doGet(HttpServletRequest req,
HttpServletResponse res)
{
if( valid)
{
RequestDispatcher rd =
req.getRequestDispatcher(“Home.jsp”)
rd.forward(req, res);
}
else
{
req.setAttribute(“error”, “username or password is
invalid”);
RequestDispatcher rd
=req.getRequestDispatcher(“Login.jsp”);
rd.forward(req, res);
}
}
Home About
L
Login.jsp
username/pwd
invalid
${requestScope.e
rror}
login
error=“username/pwd is
invalid
Page 14Classification: Restricted
JSP
• Java Server Pages
• used for developing server side response
• to add dynamic functionality to web page
• java code is written inside html
• gets the container support
• Life Cycle methods
• jspInit()
• _jspService
• jspDestroy
Page 15Classification: Restricted
Compilation & Execution
• Execution of jsp is done in two phases
• translation
• Web container translates Hello.jsp to _Hello.java
• Converts jsp to servlet
• compilation
• generates Hello.class file
• load the class file
• creates the instance of Hello
• calls init method
• call service method
• calls destroy method.
Page 16Classification: Restricted
Hello.jsp->_Hello.java
compiles _Hello.java to
_Hello.class
Page 17Classification: Restricted
_jspInit()
_jspServic
e()
_jspServic
e()
_jspServic
e()
Page 18Classification: Restricted
_jspInit()
_jspServic
e()
_jspServic
e()
_jspServic
e()
jspDestroy()
Page 19Classification: Restricted
Thank You

More Related Content

What's hot

MongoDB Performance Debugging
MongoDB Performance DebuggingMongoDB Performance Debugging
MongoDB Performance Debugging
MongoDB
 
Building High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low EffortBuilding High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low Effort
Stefan Marr
 
Nko workshop - node js crud & deploy
Nko workshop - node js crud & deployNko workshop - node js crud & deploy
Nko workshop - node js crud & deploy
Simon Su
 

What's hot (12)

BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12THBANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
 
MongoDB Performance Debugging
MongoDB Performance DebuggingMongoDB Performance Debugging
MongoDB Performance Debugging
 
How Data Flow analysis works in a static code analyzer
How Data Flow analysis works in a static code analyzerHow Data Flow analysis works in a static code analyzer
How Data Flow analysis works in a static code analyzer
 
Clang tidy
Clang tidyClang tidy
Clang tidy
 
Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...
Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...
Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...
 
Building High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low EffortBuilding High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low Effort
 
Mongodb debugging-performance-problems
Mongodb debugging-performance-problemsMongodb debugging-performance-problems
Mongodb debugging-performance-problems
 
20110514 mongo dbチューニング
20110514 mongo dbチューニング20110514 mongo dbチューニング
20110514 mongo dbチューニング
 
Nko workshop - node js crud & deploy
Nko workshop - node js crud & deployNko workshop - node js crud & deploy
Nko workshop - node js crud & deploy
 
C programming
C programmingC programming
C programming
 
JavaScript Proxy (ES6)
JavaScript Proxy (ES6)JavaScript Proxy (ES6)
JavaScript Proxy (ES6)
 
It's 10pm: Do You Know Where Your Writes Are?
It's 10pm: Do You Know Where Your Writes Are?It's 10pm: Do You Know Where Your Writes Are?
It's 10pm: Do You Know Where Your Writes Are?
 

Similar to Java Request Dispatcher

Pointcuts and Analysis
Pointcuts and AnalysisPointcuts and Analysis
Pointcuts and Analysis
Wiwat Ruengmee
 
Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)
Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)
Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)
Igalia
 

Similar to Java Request Dispatcher (20)

Compose Async with RxJS
Compose Async with RxJSCompose Async with RxJS
Compose Async with RxJS
 
Qt Network Explained (Portuguese)
Qt Network Explained (Portuguese)Qt Network Explained (Portuguese)
Qt Network Explained (Portuguese)
 
Node Anti-Patterns and Bad Practices
Node Anti-Patterns and Bad PracticesNode Anti-Patterns and Bad Practices
Node Anti-Patterns and Bad Practices
 
CodiLime Tech Talk - Katarzyna Ziomek-Zdanowicz: RxJS main concepts and real ...
CodiLime Tech Talk - Katarzyna Ziomek-Zdanowicz: RxJS main concepts and real ...CodiLime Tech Talk - Katarzyna Ziomek-Zdanowicz: RxJS main concepts and real ...
CodiLime Tech Talk - Katarzyna Ziomek-Zdanowicz: RxJS main concepts and real ...
 
Pointcuts and Analysis
Pointcuts and AnalysisPointcuts and Analysis
Pointcuts and Analysis
 
Rapid Development Tools for Java EE 8 [TUT2998]
Rapid Development Tools for Java EE 8 [TUT2998]Rapid Development Tools for Java EE 8 [TUT2998]
Rapid Development Tools for Java EE 8 [TUT2998]
 
RESTful API using scalaz (3)
RESTful API using scalaz (3)RESTful API using scalaz (3)
RESTful API using scalaz (3)
 
Rapid development tools for java ee 8 [tut2998]
Rapid development tools for java ee 8 [tut2998]Rapid development tools for java ee 8 [tut2998]
Rapid development tools for java ee 8 [tut2998]
 
Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)
Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)
Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)
 
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
 
RxJava и Android. Плюсы, минусы, подводные камни
RxJava и Android. Плюсы, минусы, подводные камниRxJava и Android. Плюсы, минусы, подводные камни
RxJava и Android. Плюсы, минусы, подводные камни
 
Leveraging your Knowledge of ORM Towards Performance-based NoSQL Technology
Leveraging your Knowledge of ORM Towards Performance-based NoSQL TechnologyLeveraging your Knowledge of ORM Towards Performance-based NoSQL Technology
Leveraging your Knowledge of ORM Towards Performance-based NoSQL Technology
 
Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17
 
Василий Сорокин, Простой REST сервер на Qt с рефлексией
Василий Сорокин, Простой REST сервер на Qt с рефлексиейВасилий Сорокин, Простой REST сервер на Qt с рефлексией
Василий Сорокин, Простой REST сервер на Qt с рефлексией
 
Rx workshop
Rx workshopRx workshop
Rx workshop
 
Exactly once with spark streaming
Exactly once with spark streamingExactly once with spark streaming
Exactly once with spark streaming
 
PHPSpec BDD for PHP
PHPSpec BDD for PHPPHPSpec BDD for PHP
PHPSpec BDD for PHP
 
Apache Spark - Basics of RDD & RDD Operations | Big Data Hadoop Spark Tutoria...
Apache Spark - Basics of RDD & RDD Operations | Big Data Hadoop Spark Tutoria...Apache Spark - Basics of RDD & RDD Operations | Big Data Hadoop Spark Tutoria...
Apache Spark - Basics of RDD & RDD Operations | Big Data Hadoop Spark Tutoria...
 
Gerenciamento de estado no Angular com NgRx
Gerenciamento de estado no Angular com NgRxGerenciamento de estado no Angular com NgRx
Gerenciamento de estado no Angular com NgRx
 
JavaEE 8 on a diet with Payara Micro 5
JavaEE 8 on a diet with Payara Micro 5JavaEE 8 on a diet with Payara Micro 5
JavaEE 8 on a diet with Payara Micro 5
 

More from AathikaJava

More from AathikaJava (17)

Java While Loop
Java While LoopJava While Loop
Java While Loop
 
Java Webservices
Java WebservicesJava Webservices
Java Webservices
 
Java Type Casting
Java Type Casting Java Type Casting
Java Type Casting
 
Spring Web MVC
Spring Web MVCSpring Web MVC
Spring Web MVC
 
Java Session
Java SessionJava Session
Java Session
 
Java Servlet Lifecycle
Java Servlet LifecycleJava Servlet Lifecycle
Java Servlet Lifecycle
 
Java Rest
Java Rest Java Rest
Java Rest
 
Java Polymorphism Part 2
Java Polymorphism Part 2Java Polymorphism Part 2
Java Polymorphism Part 2
 
Java MVC
Java MVCJava MVC
Java MVC
 
Java Polymorphism
Java PolymorphismJava Polymorphism
Java Polymorphism
 
Java Spring
Java SpringJava Spring
Java Spring
 
Mapping Classes with Relational Databases
Mapping Classes with Relational DatabasesMapping Classes with Relational Databases
Mapping Classes with Relational Databases
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
Java Encapsulation and Inheritance
Java Encapsulation and Inheritance Java Encapsulation and Inheritance
Java Encapsulation and Inheritance
 
Hibernate basics
Hibernate basicsHibernate basics
Hibernate basics
 
Java Filters
Java FiltersJava Filters
Java Filters
 
Encapsulation
EncapsulationEncapsulation
Encapsulation
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 

Java Request Dispatcher