SlideShare a Scribd company logo
1 of 17
All You Ever Wanted To Know
About Servlets
But Were Afraid to Ask
2
Three Embedded Scripting
Languages
• ASP is proprietary to Microsoft and only
works on certain servers
• JSP is an open standard for use with many
servers
• Built on Java
• PHP is open source freeware
• All allow you to insert code, objects, and do
text substitutions in webpages
3
Java Servlets
• Not as simple to use as JSP, but easier to
install
• We don't have JSP at Dal FCS
• Run on the server (like SSI or CGI)
• Threaded (unlike SSI or CGI)
• Run inside the single JVM owned by http
4
But what about mod_perl?
• mod_perl is server-side and light weight
(like a thread)
• Java has some network support that is more
sometimes more convenient than using perl
• Particularly for session tracking
5
Session Tracking With Servlets
Programs written in java produce output
which is sent to the client like any CGI
program
6
Session Tracking With Servlets
• All servlets implement the Servlet
interface or extend a class the implements it
• Important methods:
Init Service Destroy
getServletConfig getServletInfo
7
Common Methods
• We will use HttpServlet and these methods:
• doGet
• doPost
• doPut
• doDelete
• init
• destroy
• getServletInfo
• One of those methods must be overridden for each
servlet
8
Example: Hello Servlet
• Source Code
• Run it
• See Compilation Record
• Must be compiled and run from torch
• Note how it overrides the doGet method
• Which process runs the servlet?
9
Maintaining State
There are 3 ways to maintain state?
1. Cookies
2. Hidden fields in forms
3. Session level authentication
10
Maintaining State
Ways to maintain state:
1. Cookies
2. Hidden fields in forms
(or using URL rewriting to fake it)
3. Session level authentication
4. Servlets
• Uses cookies when user-agent supports it
• Uses URL rewriting if can't use cookies
11
Session Tracking
Ways to maintain state:
1. Cookies
2. Hidden fields in forms
3. URL rewriting
4. Session-level authentication
5. Servlets
• Will use cookies if possible
• Will use URL rewriting if no cookies
12
How Do Servlets
Track The Session?
• Each session has a unique ID
• The first time a session is begun an ID is
assigned
• Every subsequent connection must send the
ID (through a cookie or the URL)
13
Servlet Sessions
• HttpSession session =
request.getSession();
• If null then this is a new session
• Force a new session like this…
request.getSession(true);
14
Storing Information in Sessions
• setAttribute(String name, Object value)
• getAttribute(String name)
• removeAttribute(String name)
• getAttributeNames()
15
Information About Sessions
• getId()
• isNew()
• getCreationTime()
• getLastAccessedTime()
• getMaxInactiveInterval()
16
Example: Session Tracking
• Source Code
• Run it
Note the encoding of the URL
All examples are available at
http://www.cs.dal.ca/~jamie/CS3172/Materials/examples/servlets/
17
Questions?
• Which process executes the servlets?
• How are they like CGI programs?
• How are they different from CGI programs?
• What advantages do they have over other
technologies we've seen so far?

More Related Content

Similar to Servlets+JSP.ppt

Servlet.ppt
Servlet.pptServlet.ppt
Servlet.pptkstalin2
 
Performance of Microservice Frameworks on different JVMs
Performance of Microservice Frameworks on different JVMsPerformance of Microservice Frameworks on different JVMs
Performance of Microservice Frameworks on different JVMsMaarten Smeets
 
Enterprise java unit-2_chapter-3
Enterprise  java unit-2_chapter-3Enterprise  java unit-2_chapter-3
Enterprise java unit-2_chapter-3sandeep54552
 
Automating your php infrastructure with the zend server api
Automating your php infrastructure with the zend server apiAutomating your php infrastructure with the zend server api
Automating your php infrastructure with the zend server apiYonni Mendes
 
Integrating Servlets and JSP (The MVC Architecture)
Integrating Servlets and JSP  (The MVC Architecture)Integrating Servlets and JSP  (The MVC Architecture)
Integrating Servlets and JSP (The MVC Architecture)Amit Ranjan
 
java Servlet technology
java Servlet technologyjava Servlet technology
java Servlet technologyTanmoy Barman
 
Liit tyit sem 5 enterprise java unit 1 notes 2018
Liit tyit sem 5 enterprise java  unit 1 notes 2018 Liit tyit sem 5 enterprise java  unit 1 notes 2018
Liit tyit sem 5 enterprise java unit 1 notes 2018 tanujaparihar
 
Tdd using Jasmine and karma
Tdd using  Jasmine and karmaTdd using  Jasmine and karma
Tdd using Jasmine and karmaSiddharth Mishra
 
SQLDay2013_Denny Cherry - SQLServer2012inaHighlyAvailableWorld
SQLDay2013_Denny Cherry - SQLServer2012inaHighlyAvailableWorldSQLDay2013_Denny Cherry - SQLServer2012inaHighlyAvailableWorld
SQLDay2013_Denny Cherry - SQLServer2012inaHighlyAvailableWorldPolish SQL Server User Group
 
Using MCollective with Chef - cfgmgmtcamp.eu 2014
Using MCollective with Chef - cfgmgmtcamp.eu 2014Using MCollective with Chef - cfgmgmtcamp.eu 2014
Using MCollective with Chef - cfgmgmtcamp.eu 2014Zachary Stevens
 
Node.js to the rescue
Node.js to the rescueNode.js to the rescue
Node.js to the rescueMarko Heijnen
 

Similar to Servlets+JSP.ppt (20)

Wt unit 3
Wt unit 3 Wt unit 3
Wt unit 3
 
Servlet.ppt
Servlet.pptServlet.ppt
Servlet.ppt
 
Servlet.ppt
Servlet.pptServlet.ppt
Servlet.ppt
 
Servlet1.ppt
Servlet1.pptServlet1.ppt
Servlet1.ppt
 
Performance of Microservice Frameworks on different JVMs
Performance of Microservice Frameworks on different JVMsPerformance of Microservice Frameworks on different JVMs
Performance of Microservice Frameworks on different JVMs
 
Presentation on Web Attacks
Presentation on Web AttacksPresentation on Web Attacks
Presentation on Web Attacks
 
Advance Java
Advance JavaAdvance Java
Advance Java
 
Advanced java+JDBC+Servlet
Advanced java+JDBC+ServletAdvanced java+JDBC+Servlet
Advanced java+JDBC+Servlet
 
Enterprise java unit-2_chapter-3
Enterprise  java unit-2_chapter-3Enterprise  java unit-2_chapter-3
Enterprise java unit-2_chapter-3
 
Automating your php infrastructure with the zend server api
Automating your php infrastructure with the zend server apiAutomating your php infrastructure with the zend server api
Automating your php infrastructure with the zend server api
 
Java Servlet
Java Servlet Java Servlet
Java Servlet
 
Integrating Servlets and JSP (The MVC Architecture)
Integrating Servlets and JSP  (The MVC Architecture)Integrating Servlets and JSP  (The MVC Architecture)
Integrating Servlets and JSP (The MVC Architecture)
 
005428052.pdf
005428052.pdf005428052.pdf
005428052.pdf
 
java Servlet technology
java Servlet technologyjava Servlet technology
java Servlet technology
 
Liit tyit sem 5 enterprise java unit 1 notes 2018
Liit tyit sem 5 enterprise java  unit 1 notes 2018 Liit tyit sem 5 enterprise java  unit 1 notes 2018
Liit tyit sem 5 enterprise java unit 1 notes 2018
 
Tdd using Jasmine and karma
Tdd using  Jasmine and karmaTdd using  Jasmine and karma
Tdd using Jasmine and karma
 
Windows 8 Apps and the Outside World
Windows 8 Apps and the Outside WorldWindows 8 Apps and the Outside World
Windows 8 Apps and the Outside World
 
SQLDay2013_Denny Cherry - SQLServer2012inaHighlyAvailableWorld
SQLDay2013_Denny Cherry - SQLServer2012inaHighlyAvailableWorldSQLDay2013_Denny Cherry - SQLServer2012inaHighlyAvailableWorld
SQLDay2013_Denny Cherry - SQLServer2012inaHighlyAvailableWorld
 
Using MCollective with Chef - cfgmgmtcamp.eu 2014
Using MCollective with Chef - cfgmgmtcamp.eu 2014Using MCollective with Chef - cfgmgmtcamp.eu 2014
Using MCollective with Chef - cfgmgmtcamp.eu 2014
 
Node.js to the rescue
Node.js to the rescueNode.js to the rescue
Node.js to the rescue
 

More from EidTahir

servlets.ppt
servlets.pptservlets.ppt
servlets.pptEidTahir
 
005428058.pdf
005428058.pdf005428058.pdf
005428058.pdfEidTahir
 
005428055.pdf
005428055.pdf005428055.pdf
005428055.pdfEidTahir
 
2.J2EE_Overview.ppt
2.J2EE_Overview.ppt2.J2EE_Overview.ppt
2.J2EE_Overview.pptEidTahir
 
009458666.pdf
009458666.pdf009458666.pdf
009458666.pdfEidTahir
 
009921362.pdf
009921362.pdf009921362.pdf
009921362.pdfEidTahir
 
009577496.pdf
009577496.pdf009577496.pdf
009577496.pdfEidTahir
 
009478419.pdf
009478419.pdf009478419.pdf
009478419.pdfEidTahir
 
009445185.pdf
009445185.pdf009445185.pdf
009445185.pdfEidTahir
 
009705432.pdf
009705432.pdf009705432.pdf
009705432.pdfEidTahir
 
009694598.pdf
009694598.pdf009694598.pdf
009694598.pdfEidTahir
 
enterprisejavaunit-1chapter-2-210914075956.pdf
enterprisejavaunit-1chapter-2-210914075956.pdfenterprisejavaunit-1chapter-2-210914075956.pdf
enterprisejavaunit-1chapter-2-210914075956.pdfEidTahir
 
010118565.pdf
010118565.pdf010118565.pdf
010118565.pdfEidTahir
 
005528214.pdf
005528214.pdf005528214.pdf
005528214.pdfEidTahir
 
005432796.pdf
005432796.pdf005432796.pdf
005432796.pdfEidTahir
 
009586150.pdf
009586150.pdf009586150.pdf
009586150.pdfEidTahir
 
009551323.pdf
009551323.pdf009551323.pdf
009551323.pdfEidTahir
 
009723779.pdf
009723779.pdf009723779.pdf
009723779.pdfEidTahir
 
005443266.pdf
005443266.pdf005443266.pdf
005443266.pdfEidTahir
 

More from EidTahir (20)

servlets.ppt
servlets.pptservlets.ppt
servlets.ppt
 
005428058.pdf
005428058.pdf005428058.pdf
005428058.pdf
 
005428055.pdf
005428055.pdf005428055.pdf
005428055.pdf
 
DNS.pptx
DNS.pptxDNS.pptx
DNS.pptx
 
2.J2EE_Overview.ppt
2.J2EE_Overview.ppt2.J2EE_Overview.ppt
2.J2EE_Overview.ppt
 
009458666.pdf
009458666.pdf009458666.pdf
009458666.pdf
 
009921362.pdf
009921362.pdf009921362.pdf
009921362.pdf
 
009577496.pdf
009577496.pdf009577496.pdf
009577496.pdf
 
009478419.pdf
009478419.pdf009478419.pdf
009478419.pdf
 
009445185.pdf
009445185.pdf009445185.pdf
009445185.pdf
 
009705432.pdf
009705432.pdf009705432.pdf
009705432.pdf
 
009694598.pdf
009694598.pdf009694598.pdf
009694598.pdf
 
enterprisejavaunit-1chapter-2-210914075956.pdf
enterprisejavaunit-1chapter-2-210914075956.pdfenterprisejavaunit-1chapter-2-210914075956.pdf
enterprisejavaunit-1chapter-2-210914075956.pdf
 
010118565.pdf
010118565.pdf010118565.pdf
010118565.pdf
 
005528214.pdf
005528214.pdf005528214.pdf
005528214.pdf
 
005432796.pdf
005432796.pdf005432796.pdf
005432796.pdf
 
009586150.pdf
009586150.pdf009586150.pdf
009586150.pdf
 
009551323.pdf
009551323.pdf009551323.pdf
009551323.pdf
 
009723779.pdf
009723779.pdf009723779.pdf
009723779.pdf
 
005443266.pdf
005443266.pdf005443266.pdf
005443266.pdf
 

Recently uploaded

Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........LeaCamillePacle
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 

Recently uploaded (20)

Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 

Servlets+JSP.ppt

  • 1. All You Ever Wanted To Know About Servlets But Were Afraid to Ask
  • 2. 2 Three Embedded Scripting Languages • ASP is proprietary to Microsoft and only works on certain servers • JSP is an open standard for use with many servers • Built on Java • PHP is open source freeware • All allow you to insert code, objects, and do text substitutions in webpages
  • 3. 3 Java Servlets • Not as simple to use as JSP, but easier to install • We don't have JSP at Dal FCS • Run on the server (like SSI or CGI) • Threaded (unlike SSI or CGI) • Run inside the single JVM owned by http
  • 4. 4 But what about mod_perl? • mod_perl is server-side and light weight (like a thread) • Java has some network support that is more sometimes more convenient than using perl • Particularly for session tracking
  • 5. 5 Session Tracking With Servlets Programs written in java produce output which is sent to the client like any CGI program
  • 6. 6 Session Tracking With Servlets • All servlets implement the Servlet interface or extend a class the implements it • Important methods: Init Service Destroy getServletConfig getServletInfo
  • 7. 7 Common Methods • We will use HttpServlet and these methods: • doGet • doPost • doPut • doDelete • init • destroy • getServletInfo • One of those methods must be overridden for each servlet
  • 8. 8 Example: Hello Servlet • Source Code • Run it • See Compilation Record • Must be compiled and run from torch • Note how it overrides the doGet method • Which process runs the servlet?
  • 9. 9 Maintaining State There are 3 ways to maintain state? 1. Cookies 2. Hidden fields in forms 3. Session level authentication
  • 10. 10 Maintaining State Ways to maintain state: 1. Cookies 2. Hidden fields in forms (or using URL rewriting to fake it) 3. Session level authentication 4. Servlets • Uses cookies when user-agent supports it • Uses URL rewriting if can't use cookies
  • 11. 11 Session Tracking Ways to maintain state: 1. Cookies 2. Hidden fields in forms 3. URL rewriting 4. Session-level authentication 5. Servlets • Will use cookies if possible • Will use URL rewriting if no cookies
  • 12. 12 How Do Servlets Track The Session? • Each session has a unique ID • The first time a session is begun an ID is assigned • Every subsequent connection must send the ID (through a cookie or the URL)
  • 13. 13 Servlet Sessions • HttpSession session = request.getSession(); • If null then this is a new session • Force a new session like this… request.getSession(true);
  • 14. 14 Storing Information in Sessions • setAttribute(String name, Object value) • getAttribute(String name) • removeAttribute(String name) • getAttributeNames()
  • 15. 15 Information About Sessions • getId() • isNew() • getCreationTime() • getLastAccessedTime() • getMaxInactiveInterval()
  • 16. 16 Example: Session Tracking • Source Code • Run it Note the encoding of the URL All examples are available at http://www.cs.dal.ca/~jamie/CS3172/Materials/examples/servlets/
  • 17. 17 Questions? • Which process executes the servlets? • How are they like CGI programs? • How are they different from CGI programs? • What advantages do they have over other technologies we've seen so far?