SlideShare une entreprise Scribd logo
1  sur  25
Télécharger pour lire hors ligne
APPLICATION EVENT FRAMEWORK
Prof. AshishSingh Bhatia
1Prof. AshishSingh Bhatia
What and Why ?
 Life cycle methods
 How to respond to major events in the life cycle of the web application
?
 Who will do what ?
 Eight kind of listeners that respond to web life cycle events.
Prof. AshishSingh Bhatia 2
Listeners Interface
 ServletContextListener
 ServletContext AttributeListener
 HttpSessionListener
 HttpSessionAttributeListener
 HttpSessionActivationListener
 HttpSessionBindingListener
 ServletRequest Listener [ 2.4 ]
 ServletRequestAttributeListener [ 2.4 ]
Prof. AshishSingh Bhatia 3
How ?
 Implement the appropriate interface.
 Implement the methods needed to respond to the events of interest.
 Obtain access to the important Web application objects.
 Use these objects.
 Declare the listener.
 Provide any needed initialization parameters.
Prof. AshishSingh Bhatia 4
Take a Case Study and Think out of Box
 We are enterprise level [ Huge Company with lot many pages of web
application ]
 Where company whose name changes frequently
 We need to display company name in all pages [ Servlet / JSP ]
 How we can do that ?
Prof. AshishSingh Bhatia 5
Take a Case Study and Think out of Box
 As it is needed in application wide we will put it in web.xml as context-param
<context-param>
<param-name>companyName</param-name>
<param-value>test.com</param-value>
</context-param>
 In Servlet we will read it using
String name = getServletContext().getInitParameter(“companyName”);
Prof. AshishSingh Bhatia 6
Guess we have 100 [ Servlet / JSP ]
If we forgot to add entry in web.xml ?
Every Servlet / Page will display null
!!!!
Monitoring creation and destruction of Servlet Context
Prof. AshishSingh Bhatia 7
web.xml
Prof. AshishSingh Bhatia 8
JSP File
Prof. AshishSingh Bhatia 9
Take a new case
Prof. AshishSingh Bhatia 10
What if servlet change
the companyName of
context-param ?
Example : asbspace.in
Take a new case
Prof. AshishSingh Bhatia 11
We should ensure that when company
name is changed
formerCompanyName should also be
changed
companyName = asbspace.in
formerCompanyName=test.com
ServletContextAttributeListener
HTML Form
Prof. AshishSingh Bhatia 12
Servlet Changing Name
Prof. AshishSingh Bhatia 13
ServletContextAttributeListener
Prof. AshishSingh Bhatia 14
JSP displaying new and old name of the company
Prof. AshishSingh Bhatia 15
Session Related Listener
 For all Sessions
 ServletContextListener
 ServletContextAttributeListener
 For Specific Sessions
 HttpSessionListener
 HttpSessionAttributeListener
 Counting number of sessions
 HttpSessionListener Interface : sessionCreated and sessionDestroyed
Prof. AshishSingh Bhatia 16
Prof. AshishSingh Bhatia 17
Prof. AshishSingh Bhatia 18
test.jsp
makesession.html
sessioncount.jsp
Prof. AshishSingh Bhatia 19
Prof. AshishSingh Bhatia 20
Cookies must be disabled. So each
jsp load will act as a request and
create a new session
sessioncount.jsp output
Prof. AshishSingh Bhatia 21
Watching for changes in Session Attribute
 HttpSessionAttributeListener interface. Implement attributeAdded,
attributeReplaced, and attributeRemoved
 It gets notified when an object is placed into the session scope for the
first time, replaced by another object, or removed from the session
scope altogether.
Prof. AshishSingh Bhatia 22
Task – Self Study
 Suppose you want to track buying patterns for a specific item (a yacht, in
this case). Of course, you could try to find all servlets and JSP pages that
process orders and change each one to record yacht purchases. That’s an
awful lot of work for what sounds like a simple request, though, and pretty
hard to maintain, anyhow. A much better option is to create a session
attribute listener that monitors the attributes corresponding to order
reservations or purchases and that records the information in the log file for
later perusal by the sales manager.
Prof. AshishSingh Bhatia 23
Calculating Server Request Load
Prof. AshishSingh Bhatia 24
END OF SESSION
25Prof. AshishSingh Bhatia

Contenu connexe

Similaire à Servlet Event framework

Reviving the HTTP Service - Felix Meschberger
Reviving the HTTP Service - Felix MeschbergerReviving the HTTP Service - Felix Meschberger
Reviving the HTTP Service - Felix Meschbergermfrancis
 
Whats New in the Http Service Specification - Felix Meschberger
Whats New in the Http Service Specification - Felix MeschbergerWhats New in the Http Service Specification - Felix Meschberger
Whats New in the Http Service Specification - Felix Meschbergermfrancis
 
Restful web services_tutorial
Restful web services_tutorialRestful web services_tutorial
Restful web services_tutorialphilip75020
 
Stéphane Nicoll and Madhura Bhave at SpringOne Platform 2017
Stéphane Nicoll and Madhura Bhave at SpringOne Platform 2017Stéphane Nicoll and Madhura Bhave at SpringOne Platform 2017
Stéphane Nicoll and Madhura Bhave at SpringOne Platform 2017VMware Tanzu
 
SPFx Webinar Loading SharePoint data in a SPFx Webpart
SPFx Webinar Loading SharePoint data in a SPFx WebpartSPFx Webinar Loading SharePoint data in a SPFx Webpart
SPFx Webinar Loading SharePoint data in a SPFx WebpartJenkins NS
 
HTTP Whiteboard - OSGI Compendium 6.0 - How web apps should have been! - R Auge
HTTP Whiteboard - OSGI Compendium 6.0 - How web apps should have been! - R AugeHTTP Whiteboard - OSGI Compendium 6.0 - How web apps should have been! - R Auge
HTTP Whiteboard - OSGI Compendium 6.0 - How web apps should have been! - R Augemfrancis
 
Reactive OSGi meets Reactive Java - Don’t cross the streams - T Ward
Reactive OSGi meets Reactive Java - Don’t cross the streams - T WardReactive OSGi meets Reactive Java - Don’t cross the streams - T Ward
Reactive OSGi meets Reactive Java - Don’t cross the streams - T Wardmfrancis
 
SCULPT! YOUR! TESTS!
SCULPT! YOUR! TESTS!SCULPT! YOUR! TESTS!
SCULPT! YOUR! TESTS!Taras Oleksyn
 
Leveraging JavaScript Promises and the Bulk API
Leveraging JavaScript Promises and the Bulk APILeveraging JavaScript Promises and the Bulk API
Leveraging JavaScript Promises and the Bulk APISalesforce Developers
 
Server Side Swift - AppBuilders 2017
Server Side Swift - AppBuilders 2017Server Side Swift - AppBuilders 2017
Server Side Swift - AppBuilders 2017Jens Ravens
 
Understanding ASP.NET Under The Cover - Miguel A. Castro
Understanding ASP.NET Under The Cover - Miguel A. CastroUnderstanding ASP.NET Under The Cover - Miguel A. Castro
Understanding ASP.NET Under The Cover - Miguel A. CastroMohammad Tayseer
 
Moving full trust code to the cloud using repeatable patterns and best practices
Moving full trust code to the cloud using repeatable patterns and best practicesMoving full trust code to the cloud using repeatable patterns and best practices
Moving full trust code to the cloud using repeatable patterns and best practicesLuis Valencia
 
ASP.NET AJAX with Visual Studio 2008
ASP.NET AJAX with Visual Studio 2008ASP.NET AJAX with Visual Studio 2008
ASP.NET AJAX with Visual Studio 2008Caleb Jenkins
 
Progressive EPiServer Development
Progressive EPiServer DevelopmentProgressive EPiServer Development
Progressive EPiServer Developmentjoelabrahamsson
 
ReactJS Tutorial For Beginners | ReactJS Redux Training For Beginners | React...
ReactJS Tutorial For Beginners | ReactJS Redux Training For Beginners | React...ReactJS Tutorial For Beginners | ReactJS Redux Training For Beginners | React...
ReactJS Tutorial For Beginners | ReactJS Redux Training For Beginners | React...Edureka!
 

Similaire à Servlet Event framework (20)

Reviving the HTTP Service - Felix Meschberger
Reviving the HTTP Service - Felix MeschbergerReviving the HTTP Service - Felix Meschberger
Reviving the HTTP Service - Felix Meschberger
 
Servlets
ServletsServlets
Servlets
 
java
java java
java
 
Whats New in the Http Service Specification - Felix Meschberger
Whats New in the Http Service Specification - Felix MeschbergerWhats New in the Http Service Specification - Felix Meschberger
Whats New in the Http Service Specification - Felix Meschberger
 
Restful web services_tutorial
Restful web services_tutorialRestful web services_tutorial
Restful web services_tutorial
 
Stéphane Nicoll and Madhura Bhave at SpringOne Platform 2017
Stéphane Nicoll and Madhura Bhave at SpringOne Platform 2017Stéphane Nicoll and Madhura Bhave at SpringOne Platform 2017
Stéphane Nicoll and Madhura Bhave at SpringOne Platform 2017
 
SPFx Webinar Loading SharePoint data in a SPFx Webpart
SPFx Webinar Loading SharePoint data in a SPFx WebpartSPFx Webinar Loading SharePoint data in a SPFx Webpart
SPFx Webinar Loading SharePoint data in a SPFx Webpart
 
HTTP Whiteboard - OSGI Compendium 6.0 - How web apps should have been! - R Auge
HTTP Whiteboard - OSGI Compendium 6.0 - How web apps should have been! - R AugeHTTP Whiteboard - OSGI Compendium 6.0 - How web apps should have been! - R Auge
HTTP Whiteboard - OSGI Compendium 6.0 - How web apps should have been! - R Auge
 
Reactive OSGi meets Reactive Java - Don’t cross the streams - T Ward
Reactive OSGi meets Reactive Java - Don’t cross the streams - T WardReactive OSGi meets Reactive Java - Don’t cross the streams - T Ward
Reactive OSGi meets Reactive Java - Don’t cross the streams - T Ward
 
SCULPT! YOUR! TESTS!
SCULPT! YOUR! TESTS!SCULPT! YOUR! TESTS!
SCULPT! YOUR! TESTS!
 
Leveraging JavaScript Promises and the Bulk API
Leveraging JavaScript Promises and the Bulk APILeveraging JavaScript Promises and the Bulk API
Leveraging JavaScript Promises and the Bulk API
 
Server Side Swift - AppBuilders 2017
Server Side Swift - AppBuilders 2017Server Side Swift - AppBuilders 2017
Server Side Swift - AppBuilders 2017
 
Understanding ASP.NET Under The Cover - Miguel A. Castro
Understanding ASP.NET Under The Cover - Miguel A. CastroUnderstanding ASP.NET Under The Cover - Miguel A. Castro
Understanding ASP.NET Under The Cover - Miguel A. Castro
 
Mashups
MashupsMashups
Mashups
 
Servlet Filter
Servlet FilterServlet Filter
Servlet Filter
 
Moving full trust code to the cloud using repeatable patterns and best practices
Moving full trust code to the cloud using repeatable patterns and best practicesMoving full trust code to the cloud using repeatable patterns and best practices
Moving full trust code to the cloud using repeatable patterns and best practices
 
ASP.NET AJAX with Visual Studio 2008
ASP.NET AJAX with Visual Studio 2008ASP.NET AJAX with Visual Studio 2008
ASP.NET AJAX with Visual Studio 2008
 
Python reliable delivery
Python reliable deliveryPython reliable delivery
Python reliable delivery
 
Progressive EPiServer Development
Progressive EPiServer DevelopmentProgressive EPiServer Development
Progressive EPiServer Development
 
ReactJS Tutorial For Beginners | ReactJS Redux Training For Beginners | React...
ReactJS Tutorial For Beginners | ReactJS Redux Training For Beginners | React...ReactJS Tutorial For Beginners | ReactJS Redux Training For Beginners | React...
ReactJS Tutorial For Beginners | ReactJS Redux Training For Beginners | React...
 

Plus de AshishSingh Bhatia

Plus de AshishSingh Bhatia (6)

JSP : Creating Custom Tag
JSP : Creating Custom Tag JSP : Creating Custom Tag
JSP : Creating Custom Tag
 
Dom Basics
Dom BasicsDom Basics
Dom Basics
 
Java I/O Part 2
Java I/O Part 2Java I/O Part 2
Java I/O Part 2
 
Java I/O Part 1
Java I/O Part 1Java I/O Part 1
Java I/O Part 1
 
Nested and Enum Type in Java
Nested and Enum Type in JavaNested and Enum Type in Java
Nested and Enum Type in Java
 
Http and Servlet basics
Http and Servlet basicsHttp and Servlet basics
Http and Servlet basics
 

Dernier

fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 

Dernier (20)

fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 

Servlet Event framework

  • 1. APPLICATION EVENT FRAMEWORK Prof. AshishSingh Bhatia 1Prof. AshishSingh Bhatia
  • 2. What and Why ?  Life cycle methods  How to respond to major events in the life cycle of the web application ?  Who will do what ?  Eight kind of listeners that respond to web life cycle events. Prof. AshishSingh Bhatia 2
  • 3. Listeners Interface  ServletContextListener  ServletContext AttributeListener  HttpSessionListener  HttpSessionAttributeListener  HttpSessionActivationListener  HttpSessionBindingListener  ServletRequest Listener [ 2.4 ]  ServletRequestAttributeListener [ 2.4 ] Prof. AshishSingh Bhatia 3
  • 4. How ?  Implement the appropriate interface.  Implement the methods needed to respond to the events of interest.  Obtain access to the important Web application objects.  Use these objects.  Declare the listener.  Provide any needed initialization parameters. Prof. AshishSingh Bhatia 4
  • 5. Take a Case Study and Think out of Box  We are enterprise level [ Huge Company with lot many pages of web application ]  Where company whose name changes frequently  We need to display company name in all pages [ Servlet / JSP ]  How we can do that ? Prof. AshishSingh Bhatia 5
  • 6. Take a Case Study and Think out of Box  As it is needed in application wide we will put it in web.xml as context-param <context-param> <param-name>companyName</param-name> <param-value>test.com</param-value> </context-param>  In Servlet we will read it using String name = getServletContext().getInitParameter(“companyName”); Prof. AshishSingh Bhatia 6 Guess we have 100 [ Servlet / JSP ] If we forgot to add entry in web.xml ? Every Servlet / Page will display null !!!!
  • 7. Monitoring creation and destruction of Servlet Context Prof. AshishSingh Bhatia 7
  • 10. Take a new case Prof. AshishSingh Bhatia 10 What if servlet change the companyName of context-param ? Example : asbspace.in
  • 11. Take a new case Prof. AshishSingh Bhatia 11 We should ensure that when company name is changed formerCompanyName should also be changed companyName = asbspace.in formerCompanyName=test.com ServletContextAttributeListener
  • 13. Servlet Changing Name Prof. AshishSingh Bhatia 13
  • 15. JSP displaying new and old name of the company Prof. AshishSingh Bhatia 15
  • 16. Session Related Listener  For all Sessions  ServletContextListener  ServletContextAttributeListener  For Specific Sessions  HttpSessionListener  HttpSessionAttributeListener  Counting number of sessions  HttpSessionListener Interface : sessionCreated and sessionDestroyed Prof. AshishSingh Bhatia 16
  • 18. Prof. AshishSingh Bhatia 18 test.jsp makesession.html
  • 20. Prof. AshishSingh Bhatia 20 Cookies must be disabled. So each jsp load will act as a request and create a new session
  • 22. Watching for changes in Session Attribute  HttpSessionAttributeListener interface. Implement attributeAdded, attributeReplaced, and attributeRemoved  It gets notified when an object is placed into the session scope for the first time, replaced by another object, or removed from the session scope altogether. Prof. AshishSingh Bhatia 22
  • 23. Task – Self Study  Suppose you want to track buying patterns for a specific item (a yacht, in this case). Of course, you could try to find all servlets and JSP pages that process orders and change each one to record yacht purchases. That’s an awful lot of work for what sounds like a simple request, though, and pretty hard to maintain, anyhow. A much better option is to create a session attribute listener that monitors the attributes corresponding to order reservations or purchases and that records the information in the log file for later perusal by the sales manager. Prof. AshishSingh Bhatia 23
  • 24. Calculating Server Request Load Prof. AshishSingh Bhatia 24
  • 25. END OF SESSION 25Prof. AshishSingh Bhatia