SlideShare a Scribd company logo
AJAX
Agenda
• Asynchronous web applications
• Understand the interactions that are essential to asynchronous
web pages
• Understand the role of AJAX-style client side programming
• Implement asynchronous servlets using the facilities of Java EE
6
AJAX
• AJAX stands for Asynchronous Javascript and XML
- It Incorporates
• Standard based presentation technology using xhtml and
css
• Dynamic display and interaction using DOM
• Data interchange and manipulation using XML and
XSLT
• Asynchronous data retrieval using XMLHttpRequest
• And Javascript binding everything together
Classic Web Application
AJAX web application model
Asynchronous Support in JEE 6
• Servlet 3.0 Specs has included asynchronous support
• Annotation Attributes
- @WebServlet(url="/foo" asyncSupported=true)
- @WebFilter(url="/foo" asyncSupported=true)
• Normal Servlet runs in a Synchronous Context
• Asynchcronous Servlet run in a Asynchronous Context
Asynchronous Support in JEE 6
• ServletRequest Methods
- startAsync(ServletRequest, ServletResponse)
- startAsync()
- getAsyncContext()
• Eg
- AsyncContext aCtx= req.startAsync(req,res)
AsyncContext Class
• AsyncContext class is a new Servlet 3.0
- Provides the execution context for async operation
- It wraps the request and response Objects
- Methods
• AsyncContext.dispatch()
• AsyncContext.dispatch(path)
• AsyncContext.dispatch(ServletContext,path)
- Using any of the above methods enables the processing to
return to the container after async operation that was
started
AsyncContext Class
• AsyncContext class is a new Servlet 3.0
- Provides the execution context for async operation
- It wraps the request and response Objects
- Methods
• AsyncContext.dispatch()
• AsyncContext.dispatch(path)
• AsyncContext.dispatch(ServletContext,path)
- Using any of the above methods enables the processing to
return to the container after async operation that was
started
Async Servlet Example
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1>
<title>Asynchronous Servlet 3.0 Example</title>
</head>
<body>
<h3>Hi this is a demo example of Asynchronous Servlet 3.0 Example.</h3>
</body>
</html> <!– asyncExample.html 
Async Servlet Example
import java.io.IOException;
import java.util.Date;
import java.io.PrintWriter;
import javax.servlet.AsyncContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet(
urlPatterns = "/Servlet3AsyncExample“,asyncSupported=true)
Async Servlet Example
public class Servlet3AsyncExample extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse
response)throws ServletException, IOException{
Date date= new Date();
response.setContentType("text/html");
PrintWriter out= response.getWriter();
request.setAttribute("receivedAt", date);
out.println(request.getAttribute("receivedAt"));
AsyncContext asyncCtx = request.startAsync();
ServletRequest req = asyncCtx.getRequest();
boolean bol= req.isAsyncStarted();
//Will return true
out.println("<br>AsyncStarted : "+bol);
Async Servlet Example
asyncCtx.dispatch("/asyncExample.html");
boolean bol1= req.isAsyncStarted();
//Will return false
out.println("<br>AsyncStarted : "+bol1);
boolean bol2= req.isAsyncSupported();
//Will return true
out.println("<br>AsyncSupported : "+bol2);
}
public void doPost(HttpServletRequest request, HttpServletResponse
response)throws ServletException, IOException
{
doGet(request, response);
}
}
Summary
• AJAX comprises multiple Technology
• AJAX is extensively used in WEB 2.0
• AJAX is based on Standard technologies
• AyncSupported servlet features enables us to process incoming
request and response without being bound to original thread that
initiated the request

More Related Content

What's hot

Advance java session 9
Advance java session 9Advance java session 9
Advance java session 9
Smita B Kumar
 
Servlet and JSP
Servlet and JSPServlet and JSP
Servlet and JSP
Gary Yeh
 
MuleSoft ESB Scripting Example
MuleSoft ESB Scripting ExampleMuleSoft ESB Scripting Example
MuleSoft ESB Scripting Example
akashdprajapati
 
AngularJS
AngularJSAngularJS
AngularJS
Yogesh L
 
MuleSoft ESB Filtering data instead of Looping
MuleSoft ESB Filtering data instead of LoopingMuleSoft ESB Filtering data instead of Looping
MuleSoft ESB Filtering data instead of Looping
akashdprajapati
 
MuleSoft ESB Payload Encrypt using Anypoint Security
MuleSoft ESB Payload Encrypt using Anypoint SecurityMuleSoft ESB Payload Encrypt using Anypoint Security
MuleSoft ESB Payload Encrypt using Anypoint Security
akashdprajapati
 
MuleSoft ESB Object Store
MuleSoft ESB Object StoreMuleSoft ESB Object Store
MuleSoft ESB Object Store
akashdprajapati
 
Servlets
ServletsServlets
Servlets
ramesh kumar
 
Introduction to AJAX
Introduction to AJAXIntroduction to AJAX
Introduction to AJAX
Abzetdin Adamov
 
Ch. x web performance
Ch. x web performanceCh. x web performance
Ch. x web performance
Manolis Vavalis
 
MuleSoft ESB Shared Library
MuleSoft ESB Shared LibraryMuleSoft ESB Shared Library
MuleSoft ESB Shared Library
akashdprajapati
 
MuleSoft ESB Composite Source
MuleSoft ESB Composite SourceMuleSoft ESB Composite Source
MuleSoft ESB Composite Source
akashdprajapati
 
What's new in MySQL 5.5? FOSDEM 2011
What's new in MySQL 5.5? FOSDEM 2011What's new in MySQL 5.5? FOSDEM 2011
What's new in MySQL 5.5? FOSDEM 2011
Lenz Grimmer
 
MongoDB and MongoMK Source Event
MongoDB and MongoMK Source EventMongoDB and MongoMK Source Event
MongoDB and MongoMK Source Event
Yuval Ararat
 
MuleSoft ESB Routes first-successful
MuleSoft ESB Routes first-successfulMuleSoft ESB Routes first-successful
MuleSoft ESB Routes first-successful
akashdprajapati
 
Mini-Training: NancyFX
Mini-Training: NancyFXMini-Training: NancyFX
Mini-Training: NancyFX
Betclic Everest Group Tech Team
 
Mule esb
Mule esbMule esb
Mule esb
Khan625
 
Servlet.ppt
Servlet.pptServlet.ppt
Servlet.ppt
VMahesh5
 
Introduction to Servlets
Introduction to ServletsIntroduction to Servlets
Introduction to Servlets
Fulvio Corno
 
Caching your rails application
Caching your rails applicationCaching your rails application
Caching your rails application
ArrrrCamp
 

What's hot (20)

Advance java session 9
Advance java session 9Advance java session 9
Advance java session 9
 
Servlet and JSP
Servlet and JSPServlet and JSP
Servlet and JSP
 
MuleSoft ESB Scripting Example
MuleSoft ESB Scripting ExampleMuleSoft ESB Scripting Example
MuleSoft ESB Scripting Example
 
AngularJS
AngularJSAngularJS
AngularJS
 
MuleSoft ESB Filtering data instead of Looping
MuleSoft ESB Filtering data instead of LoopingMuleSoft ESB Filtering data instead of Looping
MuleSoft ESB Filtering data instead of Looping
 
MuleSoft ESB Payload Encrypt using Anypoint Security
MuleSoft ESB Payload Encrypt using Anypoint SecurityMuleSoft ESB Payload Encrypt using Anypoint Security
MuleSoft ESB Payload Encrypt using Anypoint Security
 
MuleSoft ESB Object Store
MuleSoft ESB Object StoreMuleSoft ESB Object Store
MuleSoft ESB Object Store
 
Servlets
ServletsServlets
Servlets
 
Introduction to AJAX
Introduction to AJAXIntroduction to AJAX
Introduction to AJAX
 
Ch. x web performance
Ch. x web performanceCh. x web performance
Ch. x web performance
 
MuleSoft ESB Shared Library
MuleSoft ESB Shared LibraryMuleSoft ESB Shared Library
MuleSoft ESB Shared Library
 
MuleSoft ESB Composite Source
MuleSoft ESB Composite SourceMuleSoft ESB Composite Source
MuleSoft ESB Composite Source
 
What's new in MySQL 5.5? FOSDEM 2011
What's new in MySQL 5.5? FOSDEM 2011What's new in MySQL 5.5? FOSDEM 2011
What's new in MySQL 5.5? FOSDEM 2011
 
MongoDB and MongoMK Source Event
MongoDB and MongoMK Source EventMongoDB and MongoMK Source Event
MongoDB and MongoMK Source Event
 
MuleSoft ESB Routes first-successful
MuleSoft ESB Routes first-successfulMuleSoft ESB Routes first-successful
MuleSoft ESB Routes first-successful
 
Mini-Training: NancyFX
Mini-Training: NancyFXMini-Training: NancyFX
Mini-Training: NancyFX
 
Mule esb
Mule esbMule esb
Mule esb
 
Servlet.ppt
Servlet.pptServlet.ppt
Servlet.ppt
 
Introduction to Servlets
Introduction to ServletsIntroduction to Servlets
Introduction to Servlets
 
Caching your rails application
Caching your rails applicationCaching your rails application
Caching your rails application
 

Similar to Advance java session 20

Servlets
ServletsServlets
Asynchronous programming in ASP.NET
Asynchronous programming in ASP.NETAsynchronous programming in ASP.NET
Asynchronous programming in ASP.NET
Alex Thissen
 
JAVA Servlets
JAVA ServletsJAVA Servlets
JAVA Servlets
deepak kumar
 
18CSC311J Web Design and Development UNIT-3
18CSC311J Web Design and Development UNIT-318CSC311J Web Design and Development UNIT-3
18CSC311J Web Design and Development UNIT-3
sivakumarmcs
 
Ajax
AjaxAjax
WEB TECHNOLOGY Unit-5.pptx
WEB TECHNOLOGY Unit-5.pptxWEB TECHNOLOGY Unit-5.pptx
WEB TECHNOLOGY Unit-5.pptx
karthiksmart21
 
Ajax
AjaxAjax
Introduction tomcat7 servlet3
Introduction tomcat7 servlet3Introduction tomcat7 servlet3
Introduction tomcat7 servlet3
JavaEE Trainers
 
Ajax
AjaxAjax
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B KuteJava Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Tushar B Kute
 
PHP - Introduction to PHP AJAX
PHP -  Introduction to PHP AJAXPHP -  Introduction to PHP AJAX
PHP - Introduction to PHP AJAX
Vibrant Technologies & Computers
 
Java Servlets.pdf
Java Servlets.pdfJava Servlets.pdf
Java Servlets.pdf
Arumugam90
 
Ajax workshop
Ajax workshopAjax workshop
Ajax workshop
WBUTTUTORIALS
 
Ajax
AjaxAjax
Synapseindia dot net development web applications with ajax
Synapseindia dot net development  web applications with ajaxSynapseindia dot net development  web applications with ajax
Synapseindia dot net development web applications with ajax
Synapseindiappsdevelopment
 
06 integrate elasticsearch
06 integrate elasticsearch06 integrate elasticsearch
06 integrate elasticsearch
Erhwen Kuo
 
Ajax ppt
Ajax pptAjax ppt
Ajax
AjaxAjax
AJAX.pptx
AJAX.pptxAJAX.pptx
AJAX.pptx
Ganesh Chavan
 
IP UNIT III PPT.pptx
 IP UNIT III PPT.pptx IP UNIT III PPT.pptx
IP UNIT III PPT.pptx
ssuser92282c
 

Similar to Advance java session 20 (20)

Servlets
ServletsServlets
Servlets
 
Asynchronous programming in ASP.NET
Asynchronous programming in ASP.NETAsynchronous programming in ASP.NET
Asynchronous programming in ASP.NET
 
JAVA Servlets
JAVA ServletsJAVA Servlets
JAVA Servlets
 
18CSC311J Web Design and Development UNIT-3
18CSC311J Web Design and Development UNIT-318CSC311J Web Design and Development UNIT-3
18CSC311J Web Design and Development UNIT-3
 
Ajax
AjaxAjax
Ajax
 
WEB TECHNOLOGY Unit-5.pptx
WEB TECHNOLOGY Unit-5.pptxWEB TECHNOLOGY Unit-5.pptx
WEB TECHNOLOGY Unit-5.pptx
 
Ajax
AjaxAjax
Ajax
 
Introduction tomcat7 servlet3
Introduction tomcat7 servlet3Introduction tomcat7 servlet3
Introduction tomcat7 servlet3
 
Ajax
AjaxAjax
Ajax
 
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B KuteJava Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
 
PHP - Introduction to PHP AJAX
PHP -  Introduction to PHP AJAXPHP -  Introduction to PHP AJAX
PHP - Introduction to PHP AJAX
 
Java Servlets.pdf
Java Servlets.pdfJava Servlets.pdf
Java Servlets.pdf
 
Ajax workshop
Ajax workshopAjax workshop
Ajax workshop
 
Ajax
AjaxAjax
Ajax
 
Synapseindia dot net development web applications with ajax
Synapseindia dot net development  web applications with ajaxSynapseindia dot net development  web applications with ajax
Synapseindia dot net development web applications with ajax
 
06 integrate elasticsearch
06 integrate elasticsearch06 integrate elasticsearch
06 integrate elasticsearch
 
Ajax ppt
Ajax pptAjax ppt
Ajax ppt
 
Ajax
AjaxAjax
Ajax
 
AJAX.pptx
AJAX.pptxAJAX.pptx
AJAX.pptx
 
IP UNIT III PPT.pptx
 IP UNIT III PPT.pptx IP UNIT III PPT.pptx
IP UNIT III PPT.pptx
 

More from Smita B Kumar

Advance java session 19
Advance java session 19Advance java session 19
Advance java session 19
Smita B Kumar
 
Advance java session 18
Advance java session 18Advance java session 18
Advance java session 18
Smita B Kumar
 
Advance java session 17
Advance java session 17Advance java session 17
Advance java session 17
Smita B Kumar
 
Advance java session 16
Advance java session 16Advance java session 16
Advance java session 16
Smita B Kumar
 
Advance java session 14
Advance java session 14Advance java session 14
Advance java session 14
Smita B Kumar
 
Advance java session 13
Advance java session 13Advance java session 13
Advance java session 13
Smita B Kumar
 
Advance java session 12
Advance java session 12Advance java session 12
Advance java session 12
Smita B Kumar
 
Advance java session 11
Advance java session 11Advance java session 11
Advance java session 11
Smita B Kumar
 
Advance java session 10
Advance java session 10Advance java session 10
Advance java session 10
Smita B Kumar
 
Advance java session 8
Advance java session 8Advance java session 8
Advance java session 8
Smita B Kumar
 
Advance java session 7
Advance java session 7Advance java session 7
Advance java session 7
Smita B Kumar
 
Advance java session 6
Advance java session 6Advance java session 6
Advance java session 6
Smita B Kumar
 
Advance java session 5
Advance java session 5Advance java session 5
Advance java session 5
Smita B Kumar
 
Advance java session 4
Advance java session 4Advance java session 4
Advance java session 4
Smita B Kumar
 
Advance java session 3
Advance java session 3Advance java session 3
Advance java session 3
Smita B Kumar
 
JEE session 1
JEE session 1JEE session 1
JEE session 1
Smita B Kumar
 
01 introduction to struts2
01 introduction to struts201 introduction to struts2
01 introduction to struts2
Smita B Kumar
 

More from Smita B Kumar (17)

Advance java session 19
Advance java session 19Advance java session 19
Advance java session 19
 
Advance java session 18
Advance java session 18Advance java session 18
Advance java session 18
 
Advance java session 17
Advance java session 17Advance java session 17
Advance java session 17
 
Advance java session 16
Advance java session 16Advance java session 16
Advance java session 16
 
Advance java session 14
Advance java session 14Advance java session 14
Advance java session 14
 
Advance java session 13
Advance java session 13Advance java session 13
Advance java session 13
 
Advance java session 12
Advance java session 12Advance java session 12
Advance java session 12
 
Advance java session 11
Advance java session 11Advance java session 11
Advance java session 11
 
Advance java session 10
Advance java session 10Advance java session 10
Advance java session 10
 
Advance java session 8
Advance java session 8Advance java session 8
Advance java session 8
 
Advance java session 7
Advance java session 7Advance java session 7
Advance java session 7
 
Advance java session 6
Advance java session 6Advance java session 6
Advance java session 6
 
Advance java session 5
Advance java session 5Advance java session 5
Advance java session 5
 
Advance java session 4
Advance java session 4Advance java session 4
Advance java session 4
 
Advance java session 3
Advance java session 3Advance java session 3
Advance java session 3
 
JEE session 1
JEE session 1JEE session 1
JEE session 1
 
01 introduction to struts2
01 introduction to struts201 introduction to struts2
01 introduction to struts2
 

Recently uploaded

How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
TIPNGVN2
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 

Recently uploaded (20)

How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 

Advance java session 20

  • 2. Agenda • Asynchronous web applications • Understand the interactions that are essential to asynchronous web pages • Understand the role of AJAX-style client side programming • Implement asynchronous servlets using the facilities of Java EE 6
  • 3. AJAX • AJAX stands for Asynchronous Javascript and XML - It Incorporates • Standard based presentation technology using xhtml and css • Dynamic display and interaction using DOM • Data interchange and manipulation using XML and XSLT • Asynchronous data retrieval using XMLHttpRequest • And Javascript binding everything together
  • 6. Asynchronous Support in JEE 6 • Servlet 3.0 Specs has included asynchronous support • Annotation Attributes - @WebServlet(url="/foo" asyncSupported=true) - @WebFilter(url="/foo" asyncSupported=true) • Normal Servlet runs in a Synchronous Context • Asynchcronous Servlet run in a Asynchronous Context
  • 7. Asynchronous Support in JEE 6 • ServletRequest Methods - startAsync(ServletRequest, ServletResponse) - startAsync() - getAsyncContext() • Eg - AsyncContext aCtx= req.startAsync(req,res)
  • 8. AsyncContext Class • AsyncContext class is a new Servlet 3.0 - Provides the execution context for async operation - It wraps the request and response Objects - Methods • AsyncContext.dispatch() • AsyncContext.dispatch(path) • AsyncContext.dispatch(ServletContext,path) - Using any of the above methods enables the processing to return to the container after async operation that was started
  • 9. AsyncContext Class • AsyncContext class is a new Servlet 3.0 - Provides the execution context for async operation - It wraps the request and response Objects - Methods • AsyncContext.dispatch() • AsyncContext.dispatch(path) • AsyncContext.dispatch(ServletContext,path) - Using any of the above methods enables the processing to return to the container after async operation that was started
  • 10. Async Servlet Example <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1> <title>Asynchronous Servlet 3.0 Example</title> </head> <body> <h3>Hi this is a demo example of Asynchronous Servlet 3.0 Example.</h3> </body> </html> <!– asyncExample.html 
  • 11. Async Servlet Example import java.io.IOException; import java.util.Date; import java.io.PrintWriter; import javax.servlet.AsyncContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet( urlPatterns = "/Servlet3AsyncExample“,asyncSupported=true)
  • 12. Async Servlet Example public class Servlet3AsyncExample extends HttpServlet{ public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException{ Date date= new Date(); response.setContentType("text/html"); PrintWriter out= response.getWriter(); request.setAttribute("receivedAt", date); out.println(request.getAttribute("receivedAt")); AsyncContext asyncCtx = request.startAsync(); ServletRequest req = asyncCtx.getRequest(); boolean bol= req.isAsyncStarted(); //Will return true out.println("<br>AsyncStarted : "+bol);
  • 13. Async Servlet Example asyncCtx.dispatch("/asyncExample.html"); boolean bol1= req.isAsyncStarted(); //Will return false out.println("<br>AsyncStarted : "+bol1); boolean bol2= req.isAsyncSupported(); //Will return true out.println("<br>AsyncSupported : "+bol2); } public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException { doGet(request, response); } }
  • 14. Summary • AJAX comprises multiple Technology • AJAX is extensively used in WEB 2.0 • AJAX is based on Standard technologies • AyncSupported servlet features enables us to process incoming request and response without being bound to original thread that initiated the request