SlideShare une entreprise Scribd logo
1  sur  7
Session Tracking DhrubojyotiKayal
HTTP is stateless Need to maintain identify clients sending requests javax.servlet.http.HttpSession is an interface that provides a way to identify a user across more than one page request or visit to a web site Useful in saving user detail, shopping carts Other mechanisms – URL rewrite, Cookies – dangerous, security issues. What is a session?
Access the session object Call request.getSession to get HttpSession object This is a hashtable associated with the user Look up information associated with a session. Call getAttribute on the HttpSessionobject Store information in a session. Use setAttribute with a key and a value. Discard session data. Call removeAttribute discards a specific value. Call invalidate to discard an entire session. getID() getAttributeNames() Returns an Enumeration of String objects containing the names of all the objects bound to this session. Session data
Write a servlet A that stores 5 integers in session Write a servlet B that echoes all the data in the session including the session id, and creation time Excerise
Some servers support distributed Web apps Load balancing used to send different requests to different machines. Sessions should still work even if different hosts are hit. On some servers, you must call setAttribute to trigger replication This is a tradeoff: session duplication can be expensive, but gives you better load balancing Distributed and PersistentSessions
Some servers support persistent sessions Session data written to disk and reloaded when server is restarted (as long as browser stays open) Tomcat 5 and 6 support this User Serializable objects to store in distributed and persistent sessions. Distributed and PersistentSessions
Q&A

Contenu connexe

Tendances

Enterprise java unit-2_chapter-2
Enterprise  java unit-2_chapter-2Enterprise  java unit-2_chapter-2
Enterprise java unit-2_chapter-2sandeep54552
 
Birhanu distributive assignment
Birhanu distributive assignmentBirhanu distributive assignment
Birhanu distributive assignmentuniversity
 
Кирилл Латыш "ERP on Websockets"
Кирилл Латыш "ERP on Websockets"Кирилл Латыш "ERP on Websockets"
Кирилл Латыш "ERP on Websockets"Fwdays
 
Advance java session 7
Advance java session 7Advance java session 7
Advance java session 7Smita B Kumar
 
Data Encryption - Azure Storage Service
Data Encryption - Azure Storage ServiceData Encryption - Azure Storage Service
Data Encryption - Azure Storage ServiceUdaiappa Ramachandran
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state managementpriya Nithya
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsCarol McDonald
 
Nuxeo - OpenSocial
Nuxeo - OpenSocialNuxeo - OpenSocial
Nuxeo - OpenSocialThomas Roger
 
Micro Web Service - Slim and JWT
Micro Web Service - Slim and JWTMicro Web Service - Slim and JWT
Micro Web Service - Slim and JWTTuyen Vuong
 
Developing on SQL Azure
Developing on SQL AzureDeveloping on SQL Azure
Developing on SQL AzureIke Ellis
 
Euruko 2009 - DataObjects
Euruko 2009 - DataObjectsEuruko 2009 - DataObjects
Euruko 2009 - DataObjectsDirkjan Bussink
 
Firebase-ized your mobile app
Firebase-ized  your mobile appFirebase-ized  your mobile app
Firebase-ized your mobile appMatteo Bonifazi
 
Suportando Aplicações Multi-tenancy com Java EE
Suportando Aplicações Multi-tenancy com Java EESuportando Aplicações Multi-tenancy com Java EE
Suportando Aplicações Multi-tenancy com Java EERodrigo Cândido da Silva
 
Azure Mobile Services .NET Backend
Azure Mobile Services .NET BackendAzure Mobile Services .NET Backend
Azure Mobile Services .NET BackendShiju Varghese
 
Advance java session 19
Advance java session 19Advance java session 19
Advance java session 19Smita B Kumar
 
Azure key vault - Brisbane User Group
Azure key vault  - Brisbane User GroupAzure key vault  - Brisbane User Group
Azure key vault - Brisbane User GroupRahul Nath
 
Dicoding Developer Coaching #20: Android | Apa itu Content Provider?
Dicoding Developer Coaching #20: Android | Apa itu Content Provider?Dicoding Developer Coaching #20: Android | Apa itu Content Provider?
Dicoding Developer Coaching #20: Android | Apa itu Content Provider?DicodingEvent
 

Tendances (20)

Enterprise java unit-2_chapter-2
Enterprise  java unit-2_chapter-2Enterprise  java unit-2_chapter-2
Enterprise java unit-2_chapter-2
 
Keystone Federation
Keystone Federation Keystone Federation
Keystone Federation
 
Birhanu distributive assignment
Birhanu distributive assignmentBirhanu distributive assignment
Birhanu distributive assignment
 
Кирилл Латыш "ERP on Websockets"
Кирилл Латыш "ERP on Websockets"Кирилл Латыш "ERP on Websockets"
Кирилл Латыш "ERP on Websockets"
 
State management
State managementState management
State management
 
Advance java session 7
Advance java session 7Advance java session 7
Advance java session 7
 
Data Encryption - Azure Storage Service
Data Encryption - Azure Storage ServiceData Encryption - Azure Storage Service
Data Encryption - Azure Storage Service
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state management
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.js
 
Nuxeo - OpenSocial
Nuxeo - OpenSocialNuxeo - OpenSocial
Nuxeo - OpenSocial
 
Micro Web Service - Slim and JWT
Micro Web Service - Slim and JWTMicro Web Service - Slim and JWT
Micro Web Service - Slim and JWT
 
Azure DocumentDB
Azure DocumentDBAzure DocumentDB
Azure DocumentDB
 
Developing on SQL Azure
Developing on SQL AzureDeveloping on SQL Azure
Developing on SQL Azure
 
Euruko 2009 - DataObjects
Euruko 2009 - DataObjectsEuruko 2009 - DataObjects
Euruko 2009 - DataObjects
 
Firebase-ized your mobile app
Firebase-ized  your mobile appFirebase-ized  your mobile app
Firebase-ized your mobile app
 
Suportando Aplicações Multi-tenancy com Java EE
Suportando Aplicações Multi-tenancy com Java EESuportando Aplicações Multi-tenancy com Java EE
Suportando Aplicações Multi-tenancy com Java EE
 
Azure Mobile Services .NET Backend
Azure Mobile Services .NET BackendAzure Mobile Services .NET Backend
Azure Mobile Services .NET Backend
 
Advance java session 19
Advance java session 19Advance java session 19
Advance java session 19
 
Azure key vault - Brisbane User Group
Azure key vault  - Brisbane User GroupAzure key vault  - Brisbane User Group
Azure key vault - Brisbane User Group
 
Dicoding Developer Coaching #20: Android | Apa itu Content Provider?
Dicoding Developer Coaching #20: Android | Apa itu Content Provider?Dicoding Developer Coaching #20: Android | Apa itu Content Provider?
Dicoding Developer Coaching #20: Android | Apa itu Content Provider?
 

En vedette (20)

Lecture 3: Servlets - Session Management
Lecture 3:  Servlets - Session ManagementLecture 3:  Servlets - Session Management
Lecture 3: Servlets - Session Management
 
Servlet Filter
Servlet FilterServlet Filter
Servlet Filter
 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods ppt
 
16 containers
16   containers16   containers
16 containers
 
Get and post methods
Get and post methodsGet and post methods
Get and post methods
 
Jsp
JspJsp
Jsp
 
Jsp
JspJsp
Jsp
 
Jsp (java server page)
Jsp (java server page)Jsp (java server page)
Jsp (java server page)
 
Jsp Introduction Tutorial
Jsp Introduction TutorialJsp Introduction Tutorial
Jsp Introduction Tutorial
 
Java servlets
Java servletsJava servlets
Java servlets
 
JSP
JSPJSP
JSP
 
Jsp chapter 1
Jsp chapter 1Jsp chapter 1
Jsp chapter 1
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Jsp presentation
Jsp presentationJsp presentation
Jsp presentation
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
 
HTTP Basics
HTTP BasicsHTTP Basics
HTTP Basics
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
HyperText Transfer Protocol (HTTP)
HyperText Transfer Protocol (HTTP)HyperText Transfer Protocol (HTTP)
HyperText Transfer Protocol (HTTP)
 
Lecture17
Lecture17Lecture17
Lecture17
 

Similaire à 01 session tracking

Advance java session 8
Advance java session 8Advance java session 8
Advance java session 8Smita B Kumar
 
Jsp session tracking
Jsp   session trackingJsp   session tracking
Jsp session trackingrvarshneyp
 
Session Tracking in servlets
Session Tracking in servletsSession Tracking in servlets
Session Tracking in servletschauhankapil
 
Session 33 - Session Management using other Techniques
Session 33 - Session Management using other TechniquesSession 33 - Session Management using other Techniques
Session 33 - Session Management using other TechniquesPawanMM
 
Session viii(state mngtserver)
Session viii(state mngtserver)Session viii(state mngtserver)
Session viii(state mngtserver)Shrijan Tiwari
 
RESTful Services for the Programmable Web with Windows Communication Foundation
RESTful Services for the Programmable Web with Windows Communication FoundationRESTful Services for the Programmable Web with Windows Communication Foundation
RESTful Services for the Programmable Web with Windows Communication Foundationgoodfriday
 
Session Management
Session  ManagementSession  Management
Session Managementpatinijava
 
Authentication
AuthenticationAuthentication
Authenticationsoon
 
Web Technologies -- Servlets 4 unit slides
Web Technologies -- Servlets   4 unit slidesWeb Technologies -- Servlets   4 unit slides
Web Technologies -- Servlets 4 unit slidesSasidhar Kothuru
 
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showThe complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showSubhas Malik
 
season management in php (WT)
season management in php (WT)season management in php (WT)
season management in php (WT)kunjan shah
 

Similaire à 01 session tracking (20)

Lecture8
Lecture8Lecture8
Lecture8
 
Advance java session 8
Advance java session 8Advance java session 8
Advance java session 8
 
Jsp session tracking
Jsp   session trackingJsp   session tracking
Jsp session tracking
 
Session Tracking in servlets
Session Tracking in servletsSession Tracking in servlets
Session Tracking in servlets
 
Http session (Java)
Http session (Java)Http session (Java)
Http session (Java)
 
self des session_T_M
self des session_T_Mself des session_T_M
self des session_T_M
 
Session 33 - Session Management using other Techniques
Session 33 - Session Management using other TechniquesSession 33 - Session Management using other Techniques
Session 33 - Session Management using other Techniques
 
Session viii(state mngtserver)
Session viii(state mngtserver)Session viii(state mngtserver)
Session viii(state mngtserver)
 
RESTful Services for the Programmable Web with Windows Communication Foundation
RESTful Services for the Programmable Web with Windows Communication FoundationRESTful Services for the Programmable Web with Windows Communication Foundation
RESTful Services for the Programmable Web with Windows Communication Foundation
 
Servlets
ServletsServlets
Servlets
 
Session Management
Session  ManagementSession  Management
Session Management
 
S8-Session Managment
S8-Session ManagmentS8-Session Managment
S8-Session Managment
 
Authentication
AuthenticationAuthentication
Authentication
 
Session management
Session management  Session management
Session management
 
Web Technologies -- Servlets 4 unit slides
Web Technologies -- Servlets   4 unit slidesWeb Technologies -- Servlets   4 unit slides
Web Technologies -- Servlets 4 unit slides
 
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showThe complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
 
ASP.NET Lecture 2
ASP.NET Lecture 2ASP.NET Lecture 2
ASP.NET Lecture 2
 
Working with Servlets
Working with ServletsWorking with Servlets
Working with Servlets
 
season management in php (WT)
season management in php (WT)season management in php (WT)
season management in php (WT)
 
Day7
Day7Day7
Day7
 

Plus de dhrubo kayal

03 handling requests
03 handling requests03 handling requests
03 handling requestsdhrubo kayal
 
02 up close with servlets
02 up close with servlets02 up close with servlets
02 up close with servletsdhrubo kayal
 
01 overview-servlets-and-environment-setup
01 overview-servlets-and-environment-setup01 overview-servlets-and-environment-setup
01 overview-servlets-and-environment-setupdhrubo kayal
 
14 initialization & cleanup
14   initialization & cleanup14   initialization & cleanup
14 initialization & cleanupdhrubo kayal
 
08 class and object
08   class and object08   class and object
08 class and objectdhrubo kayal
 
04 data types & variables
04   data types & variables04   data types & variables
04 data types & variablesdhrubo kayal
 
03 hello world with java
03   hello world with java03   hello world with java
03 hello world with javadhrubo kayal
 

Plus de dhrubo kayal (20)

Cipla 20-09-2010
Cipla   20-09-2010Cipla   20-09-2010
Cipla 20-09-2010
 
03 handling requests
03 handling requests03 handling requests
03 handling requests
 
02 up close with servlets
02 up close with servlets02 up close with servlets
02 up close with servlets
 
01 overview-servlets-and-environment-setup
01 overview-servlets-and-environment-setup01 overview-servlets-and-environment-setup
01 overview-servlets-and-environment-setup
 
19 reflection
19   reflection19   reflection
19 reflection
 
18 concurrency
18   concurrency18   concurrency
18 concurrency
 
17 exceptions
17   exceptions17   exceptions
17 exceptions
 
15 interfaces
15   interfaces15   interfaces
15 interfaces
 
14 initialization & cleanup
14   initialization & cleanup14   initialization & cleanup
14 initialization & cleanup
 
13 inheritance
13   inheritance13   inheritance
13 inheritance
 
12 encapsulation
12   encapsulation12   encapsulation
12 encapsulation
 
11 static
11   static11   static
11 static
 
10 access control
10   access control10   access control
10 access control
 
09 packages
09   packages09   packages
09 packages
 
08 class and object
08   class and object08   class and object
08 class and object
 
07 flow control
07   flow control07   flow control
07 flow control
 
05 operators
05   operators05   operators
05 operators
 
04 data types & variables
04   data types & variables04   data types & variables
04 data types & variables
 
03 hello world with java
03   hello world with java03   hello world with java
03 hello world with java
 
02 what is java
02   what is java02   what is java
02 what is java
 

01 session tracking

  • 2. HTTP is stateless Need to maintain identify clients sending requests javax.servlet.http.HttpSession is an interface that provides a way to identify a user across more than one page request or visit to a web site Useful in saving user detail, shopping carts Other mechanisms – URL rewrite, Cookies – dangerous, security issues. What is a session?
  • 3. Access the session object Call request.getSession to get HttpSession object This is a hashtable associated with the user Look up information associated with a session. Call getAttribute on the HttpSessionobject Store information in a session. Use setAttribute with a key and a value. Discard session data. Call removeAttribute discards a specific value. Call invalidate to discard an entire session. getID() getAttributeNames() Returns an Enumeration of String objects containing the names of all the objects bound to this session. Session data
  • 4. Write a servlet A that stores 5 integers in session Write a servlet B that echoes all the data in the session including the session id, and creation time Excerise
  • 5. Some servers support distributed Web apps Load balancing used to send different requests to different machines. Sessions should still work even if different hosts are hit. On some servers, you must call setAttribute to trigger replication This is a tradeoff: session duplication can be expensive, but gives you better load balancing Distributed and PersistentSessions
  • 6. Some servers support persistent sessions Session data written to disk and reloaded when server is restarted (as long as browser stays open) Tomcat 5 and 6 support this User Serializable objects to store in distributed and persistent sessions. Distributed and PersistentSessions
  • 7. Q&A