SlideShare ist ein Scribd-Unternehmen logo
1 von 52
Downloaden Sie, um offline zu lesen
Copyright Š 2002 ProsoftTraining. All rights reserved.
Java Servlets
Copyright Š 2002 ProsoftTraining. All rights reserved.
Lesson 1:
Introduction
to Java Servlets
Objectives
• Describe the differences between servlets and
other Web application technologies
• Explain the difference between the GET and
POST methods of making an HTTP request
• Create a simple servlet using GET
• Create a simple servlet using POST
• Define a simple deployment descriptor
Introduction
to Web Applications
• Web application technologies
– Common Gateway Interface (CGI)
– Server extensions
– Server-side scripting
– JavaServer Pages
– Java servlets
Hypertext
Transfer Protocol
• The GET method
• The POST method
• Additional methods
Writing a
Simple Servlet
javax.servlet.Servlet
GenericServlet HttpServlet
Responding
to Form Data
• FormServlet
• getParameter method
• Using the POST method
Deployment
Descriptors
• XML files conforming to Sun Microsystems
DTD
– Describes servlets contained within a Web
application
Summary
 Describe the differences between servlets and
other Web application technologies
 Explain the difference between the GET and
POST methods of making an HTTP request
 Create a simple servlet using GET
 Create a simple servlet using POST
 Define a simple deployment descriptor
Copyright Š 2002 ProsoftTraining. All rights reserved.
Lesson 2:
The Servlet Life Cycle
Objectives
• Describe the servlet life cycle
• Create init and destroy methods
• Retrieve servlet initialization parameters
• Use the SingleThreadModel interface
• Retrieve CGI environment variables
• Retrieve and use the ServletContext object
• Use temporary files
The
Multithreaded Model
• Servlets typically operate in a multithreaded
environment
– The Web server usually instantiates only
one instance of a servlet to serve all clients
• Deployment descriptors and the multithreaded
model
The
Single Thread Model
• The Web server guarantees that no two threads
will ever operate concurrently on the same servlet
instance
• To designate servlets to use the single thread
model, implement the following interface:
– javax.servlet.SingleThreadModel
The init
and destroy Methods
• The init method
– Initialization parameters and the
deployment descriptor
• The destroy method
CGI
Environment Variables
• AUTH_TYPE
• CONTENT_LENGTH
• CONTENT_TYPE
• HTTP_ACCEPT
• HTTP_REFERER
• HTTP_USER_AGENT
• PATH_INFO
• PATH_TRANSLATED
• QUERY_STRING
• REMOTE_ADDR
• REMOTE_HOST
• REMOTE_USER
• REQUEST_METHOD
• SCRIPT_NAME
• SERVER_NAME
• SERVER_PROTOCOL
• SERVER_PORT
The ServletContext
• Methods for obtaining server information
• Using temporary files
Summary
 Describe the servlet life cycle
 Create init and destroy methods
 Retrieve servlet initialization parameters
 Use the SingleThreadModel interface
 Retrieve CGI environment variables
 Retrieve and use the ServletContext object
 Use temporary files
Copyright Š 2002 ProsoftTraining. All rights reserved.
Lesson 3:
Responding to a Request
Objectives
• Use client-side caching
• Use client pull to update a client
• Redirect the client to another URL
• Use persistent connections
• Use response status codes
• Return a file to a client
• Dynamically generate images
Controlling
the Client
• Using client-side caching
• Using client pull
• Redirecting the client
Persistent
Connections
public class PersistentConnection extends HttpServlet
{
public void doGet(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException, IOException
{
resp.setBufferSize(32 * 1024);
resp.setContentType("text/html");
PrintWriter out = resp.getWriter();
// Generate a response
}
}
Status Codes
• Status code constants
• sendError method used to set status code
Multimedia Content
• Returning a file
• Dynamically generating images
Summary
 Use client-side caching
 Use client pull to update a client
 Redirect the client to another URL
 Use persistent connections
 Use response status codes
 Return a file to a client
 Dynamically generate images
Copyright Š 2002 ProsoftTraining. All rights reserved.
Lesson 4:
Servlet Sessions
Objectives
• Track a session using hidden form fields
• Track a session using URL rewriting
• Track a session using cookies
Hidden
Form Fields
<INPUT TYPE="HIDDEN" NAME="SID" VALUE="1234567890">
Hidden form field named "SID"
with an assigned value of
"1234567890"
URL
Rewriting
• Servlets can build URLS that add information
in the form of additional path information
Cookies
• Small pieces of information transmitted from a
Web server to a Web browser
• Represented in Java using the Cookie class
Summary
 Track a session using hidden form fields
 Track a session using URL rewriting
 Track a session using cookies
Copyright Š 2002 ProsoftTraining. All rights reserved.
Lesson 5:
Authentication
and Security
Objectives
• Authenticate a user using HTTP-based
authentication
• Authenticate a user using a form
• Use Secure Sockets Layer to improve security
HTTP-Based
Authentication
• Users
• The deployment descriptor
• Servlets and authentication
Form
Authentication
• Requires modification of the deployment
descriptor
– The login-config element must be
modified to indicate that form
authentication is to be used and to provide
the URL for a login page and login error
page
Summary
 Authenticate a user using HTTP-based
authentication
 Authenticate a user using a form
 Use Secure Sockets Layer to improve security
Copyright Š 2002 ProsoftTraining. All rights reserved.
Lesson 6:
Inter-Servlet
Communication
Objectives
• Share data with another servlet
• Handle a single request using multiple
servlets
Sharing Data
• Data-sharing methods of the
ServletContext interface
• Sharing data with another ServletContext
Dispatching
to Another Servlet
• The forward method
• The include method
Summary
 Share data with another servlet
 Handle a single request using multiple
servlets
Copyright Š 2002 ProsoftTraining. All rights reserved.
Lesson 7:
Building Enterprise
Web Applications
Objectives
• Use JNDI to look up EJBs, resource factories
and environment entries
• Write servlets for use in a distributed
environment
• Use JavaMail to send e-mail
Java Servlets and JNDI
• Referencing EJBs
• Referencing resource factories
• Referencing environment entries
Clustering
and Java Servlets
• Clustering styles
• Developing distributable servlets
JavaMail
• Add-on API that creates a full-fledged
POP/iMAP client
– Session class
– getDefaultInstance static method
Summary
 Use JNDI to look up EJBs, resource factories
and environment entries
 Write servlets for use in a distributed
environment
 Use JavaMail to send e-mail
Copyright Š 2002 ProsoftTraining. All rights reserved.
Lesson 8:
Internationalization
Objectives
• Use the Unicode escape sequence to specify
special Latin characters
• Use alternative character sets to generate a
non-Latin character response
The Latin
Character Set
• Non-English Latin characters
• Languages and language codes
Non-Latin
Character Sets
• Arabic
• Chinese
• Japanese
• Korean
• Russian
Summary
 Use the Unicode escape sequence to specify
special Latin characters
 Use alternative character sets to generate a
non-Latin character response
Java Servlets
 Introduction to Java Servlets
 The Servlet Life Cycle
 Responding to a Request
 Servlet Sessions
 Authentication and Security
 Inter-Servlet Communication
 Building Enterprise Web Applications
 Internationalization

Weitere ähnliche Inhalte

Ähnlich wie 005428052.pdf

Session 34 - JDBC Best Practices, Introduction to Design Patterns
Session 34 - JDBC Best Practices, Introduction to Design PatternsSession 34 - JDBC Best Practices, Introduction to Design Patterns
Session 34 - JDBC Best Practices, Introduction to Design PatternsPawanMM
 
IP UNIT III PPT.pptx
 IP UNIT III PPT.pptx IP UNIT III PPT.pptx
IP UNIT III PPT.pptxssuser92282c
 
Asp.Net MVC 5 in Arabic
Asp.Net MVC 5 in ArabicAsp.Net MVC 5 in Arabic
Asp.Net MVC 5 in ArabicHaitham Shaddad
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postvamsitricks
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postvamsi krishna
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postvamsitricks
 
Java Servlet
Java Servlet Java Servlet
Java Servlet Rajiv Gupta
 
Node.js to the rescue
Node.js to the rescueNode.js to the rescue
Node.js to the rescueMarko Heijnen
 
Session 26 - Servlets Part 2
Session 26 - Servlets Part 2Session 26 - Servlets Part 2
Session 26 - Servlets Part 2PawanMM
 
Web Development using ASP.NET MVC at HEC
Web Development using ASP.NET MVC at HECWeb Development using ASP.NET MVC at HEC
Web Development using ASP.NET MVC at HECAdil Mughal
 
UWP apps development - Part 2
UWP apps development - Part 2UWP apps development - Part 2
UWP apps development - Part 2Jiri Danihelka
 
Bt0083 server side programing
Bt0083 server side programing Bt0083 server side programing
Bt0083 server side programing Techglyphs
 
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
 
Structured Functional Automated Web Service Testing
Structured Functional Automated Web Service TestingStructured Functional Automated Web Service Testing
Structured Functional Automated Web Service Testingrdekleijn
 
Mastering asp.net mvc - Dot Net Tricks
Mastering asp.net mvc - Dot Net TricksMastering asp.net mvc - Dot Net Tricks
Mastering asp.net mvc - Dot Net TricksGaurav Singh
 
Angular js 1.0-fundamentals
Angular js 1.0-fundamentalsAngular js 1.0-fundamentals
Angular js 1.0-fundamentalsVenkatesh Narayanan
 
Advance java session 2
Advance java session 2Advance java session 2
Advance java session 2Smita B Kumar
 
6 Months Dotnet internship in Noida
6 Months Dotnet internship in Noida6 Months Dotnet internship in Noida
6 Months Dotnet internship in NoidaTech Mentro
 

Ähnlich wie 005428052.pdf (20)

Session 34 - JDBC Best Practices, Introduction to Design Patterns
Session 34 - JDBC Best Practices, Introduction to Design PatternsSession 34 - JDBC Best Practices, Introduction to Design Patterns
Session 34 - JDBC Best Practices, Introduction to Design Patterns
 
IP UNIT III PPT.pptx
 IP UNIT III PPT.pptx IP UNIT III PPT.pptx
IP UNIT III PPT.pptx
 
Asp.Net MVC 5 in Arabic
Asp.Net MVC 5 in ArabicAsp.Net MVC 5 in Arabic
Asp.Net MVC 5 in Arabic
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
 
CS8651 IP Unit 3.pptx
CS8651 IP Unit 3.pptxCS8651 IP Unit 3.pptx
CS8651 IP Unit 3.pptx
 
Servlets
ServletsServlets
Servlets
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
 
Java Servlet
Java Servlet Java Servlet
Java Servlet
 
Node.js to the rescue
Node.js to the rescueNode.js to the rescue
Node.js to the rescue
 
Session 26 - Servlets Part 2
Session 26 - Servlets Part 2Session 26 - Servlets Part 2
Session 26 - Servlets Part 2
 
Web Development using ASP.NET MVC at HEC
Web Development using ASP.NET MVC at HECWeb Development using ASP.NET MVC at HEC
Web Development using ASP.NET MVC at HEC
 
UWP apps development - Part 2
UWP apps development - Part 2UWP apps development - Part 2
UWP apps development - Part 2
 
Bt0083 server side programing
Bt0083 server side programing Bt0083 server side programing
Bt0083 server side programing
 
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)
 
Structured Functional Automated Web Service Testing
Structured Functional Automated Web Service TestingStructured Functional Automated Web Service Testing
Structured Functional Automated Web Service Testing
 
Mastering asp.net mvc - Dot Net Tricks
Mastering asp.net mvc - Dot Net TricksMastering asp.net mvc - Dot Net Tricks
Mastering asp.net mvc - Dot Net Tricks
 
Angular js 1.0-fundamentals
Angular js 1.0-fundamentalsAngular js 1.0-fundamentals
Angular js 1.0-fundamentals
 
Advance java session 2
Advance java session 2Advance java session 2
Advance java session 2
 
6 Months Dotnet internship in Noida
6 Months Dotnet internship in Noida6 Months Dotnet internship in Noida
6 Months Dotnet internship in Noida
 

Mehr von KalsoomTahir2

HASH FUNCTIONS.pdf
HASH FUNCTIONS.pdfHASH FUNCTIONS.pdf
HASH FUNCTIONS.pdfKalsoomTahir2
 
6. McCall's Model.pptx
6. McCall's Model.pptx6. McCall's Model.pptx
6. McCall's Model.pptxKalsoomTahir2
 
ch02-Database System Concepts and Architecture.ppt
ch02-Database System Concepts and Architecture.pptch02-Database System Concepts and Architecture.ppt
ch02-Database System Concepts and Architecture.pptKalsoomTahir2
 
chap05-info366.ppt
chap05-info366.pptchap05-info366.ppt
chap05-info366.pptKalsoomTahir2
 
soa_and_jra.ppt
soa_and_jra.pptsoa_and_jra.ppt
soa_and_jra.pptKalsoomTahir2
 
ERP_Up_Down.ppt
ERP_Up_Down.pptERP_Up_Down.ppt
ERP_Up_Down.pptKalsoomTahir2
 
Topic1CourseIntroduction.ppt
Topic1CourseIntroduction.pptTopic1CourseIntroduction.ppt
Topic1CourseIntroduction.pptKalsoomTahir2
 
Lecture 19 - Dynamic Web - JAVA - Part 1.ppt
Lecture 19 - Dynamic Web - JAVA - Part 1.pptLecture 19 - Dynamic Web - JAVA - Part 1.ppt
Lecture 19 - Dynamic Web - JAVA - Part 1.pptKalsoomTahir2
 
CommercialSystemsBahman.ppt
CommercialSystemsBahman.pptCommercialSystemsBahman.ppt
CommercialSystemsBahman.pptKalsoomTahir2
 
EJBDetailsFeb25.ppt
EJBDetailsFeb25.pptEJBDetailsFeb25.ppt
EJBDetailsFeb25.pptKalsoomTahir2
 

Mehr von KalsoomTahir2 (20)

005813616.pdf
005813616.pdf005813616.pdf
005813616.pdf
 
009576860.pdf
009576860.pdf009576860.pdf
009576860.pdf
 
005813185.pdf
005813185.pdf005813185.pdf
005813185.pdf
 
HASH FUNCTIONS.pdf
HASH FUNCTIONS.pdfHASH FUNCTIONS.pdf
HASH FUNCTIONS.pdf
 
6. McCall's Model.pptx
6. McCall's Model.pptx6. McCall's Model.pptx
6. McCall's Model.pptx
 
ch02-Database System Concepts and Architecture.ppt
ch02-Database System Concepts and Architecture.pptch02-Database System Concepts and Architecture.ppt
ch02-Database System Concepts and Architecture.ppt
 
9223301.ppt
9223301.ppt9223301.ppt
9223301.ppt
 
11885558.ppt
11885558.ppt11885558.ppt
11885558.ppt
 
Indexing.ppt
Indexing.pptIndexing.ppt
Indexing.ppt
 
chap05-info366.ppt
chap05-info366.pptchap05-info366.ppt
chap05-info366.ppt
 
1650607.ppt
1650607.ppt1650607.ppt
1650607.ppt
 
005281271.pdf
005281271.pdf005281271.pdf
005281271.pdf
 
soa_and_jra.ppt
soa_and_jra.pptsoa_and_jra.ppt
soa_and_jra.ppt
 
ERP_Up_Down.ppt
ERP_Up_Down.pptERP_Up_Down.ppt
ERP_Up_Down.ppt
 
Topic1CourseIntroduction.ppt
Topic1CourseIntroduction.pptTopic1CourseIntroduction.ppt
Topic1CourseIntroduction.ppt
 
Lecture 19 - Dynamic Web - JAVA - Part 1.ppt
Lecture 19 - Dynamic Web - JAVA - Part 1.pptLecture 19 - Dynamic Web - JAVA - Part 1.ppt
Lecture 19 - Dynamic Web - JAVA - Part 1.ppt
 
CommercialSystemsBahman.ppt
CommercialSystemsBahman.pptCommercialSystemsBahman.ppt
CommercialSystemsBahman.ppt
 
EJBDetailsFeb25.ppt
EJBDetailsFeb25.pptEJBDetailsFeb25.ppt
EJBDetailsFeb25.ppt
 
jan28EAI.ppt
jan28EAI.pptjan28EAI.ppt
jan28EAI.ppt
 
jini-1.ppt
jini-1.pptjini-1.ppt
jini-1.ppt
 

KĂźrzlich hochgeladen

How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
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
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 

KĂźrzlich hochgeladen (20)

How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
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...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 

005428052.pdf

  • 1. Copyright Š 2002 ProsoftTraining. All rights reserved. Java Servlets
  • 2. Copyright Š 2002 ProsoftTraining. All rights reserved. Lesson 1: Introduction to Java Servlets
  • 3. Objectives • Describe the differences between servlets and other Web application technologies • Explain the difference between the GET and POST methods of making an HTTP request • Create a simple servlet using GET • Create a simple servlet using POST • Define a simple deployment descriptor
  • 4. Introduction to Web Applications • Web application technologies – Common Gateway Interface (CGI) – Server extensions – Server-side scripting – JavaServer Pages – Java servlets
  • 5. Hypertext Transfer Protocol • The GET method • The POST method • Additional methods
  • 7. Responding to Form Data • FormServlet • getParameter method • Using the POST method
  • 8. Deployment Descriptors • XML files conforming to Sun Microsystems DTD – Describes servlets contained within a Web application
  • 9. Summary  Describe the differences between servlets and other Web application technologies  Explain the difference between the GET and POST methods of making an HTTP request  Create a simple servlet using GET  Create a simple servlet using POST  Define a simple deployment descriptor
  • 10. Copyright Š 2002 ProsoftTraining. All rights reserved. Lesson 2: The Servlet Life Cycle
  • 11. Objectives • Describe the servlet life cycle • Create init and destroy methods • Retrieve servlet initialization parameters • Use the SingleThreadModel interface • Retrieve CGI environment variables • Retrieve and use the ServletContext object • Use temporary files
  • 12. The Multithreaded Model • Servlets typically operate in a multithreaded environment – The Web server usually instantiates only one instance of a servlet to serve all clients • Deployment descriptors and the multithreaded model
  • 13. The Single Thread Model • The Web server guarantees that no two threads will ever operate concurrently on the same servlet instance • To designate servlets to use the single thread model, implement the following interface: – javax.servlet.SingleThreadModel
  • 14. The init and destroy Methods • The init method – Initialization parameters and the deployment descriptor • The destroy method
  • 15. CGI Environment Variables • AUTH_TYPE • CONTENT_LENGTH • CONTENT_TYPE • HTTP_ACCEPT • HTTP_REFERER • HTTP_USER_AGENT • PATH_INFO • PATH_TRANSLATED • QUERY_STRING • REMOTE_ADDR • REMOTE_HOST • REMOTE_USER • REQUEST_METHOD • SCRIPT_NAME • SERVER_NAME • SERVER_PROTOCOL • SERVER_PORT
  • 16. The ServletContext • Methods for obtaining server information • Using temporary files
  • 17. Summary  Describe the servlet life cycle  Create init and destroy methods  Retrieve servlet initialization parameters  Use the SingleThreadModel interface  Retrieve CGI environment variables  Retrieve and use the ServletContext object  Use temporary files
  • 18. Copyright Š 2002 ProsoftTraining. All rights reserved. Lesson 3: Responding to a Request
  • 19. Objectives • Use client-side caching • Use client pull to update a client • Redirect the client to another URL • Use persistent connections • Use response status codes • Return a file to a client • Dynamically generate images
  • 20. Controlling the Client • Using client-side caching • Using client pull • Redirecting the client
  • 21. Persistent Connections public class PersistentConnection extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setBufferSize(32 * 1024); resp.setContentType("text/html"); PrintWriter out = resp.getWriter(); // Generate a response } }
  • 22. Status Codes • Status code constants • sendError method used to set status code
  • 23. Multimedia Content • Returning a file • Dynamically generating images
  • 24. Summary  Use client-side caching  Use client pull to update a client  Redirect the client to another URL  Use persistent connections  Use response status codes  Return a file to a client  Dynamically generate images
  • 25. Copyright Š 2002 ProsoftTraining. All rights reserved. Lesson 4: Servlet Sessions
  • 26. Objectives • Track a session using hidden form fields • Track a session using URL rewriting • Track a session using cookies
  • 27. Hidden Form Fields <INPUT TYPE="HIDDEN" NAME="SID" VALUE="1234567890"> Hidden form field named "SID" with an assigned value of "1234567890"
  • 28. URL Rewriting • Servlets can build URLS that add information in the form of additional path information
  • 29. Cookies • Small pieces of information transmitted from a Web server to a Web browser • Represented in Java using the Cookie class
  • 30. Summary  Track a session using hidden form fields  Track a session using URL rewriting  Track a session using cookies
  • 31. Copyright Š 2002 ProsoftTraining. All rights reserved. Lesson 5: Authentication and Security
  • 32. Objectives • Authenticate a user using HTTP-based authentication • Authenticate a user using a form • Use Secure Sockets Layer to improve security
  • 33. HTTP-Based Authentication • Users • The deployment descriptor • Servlets and authentication
  • 34. Form Authentication • Requires modification of the deployment descriptor – The login-config element must be modified to indicate that form authentication is to be used and to provide the URL for a login page and login error page
  • 35. Summary  Authenticate a user using HTTP-based authentication  Authenticate a user using a form  Use Secure Sockets Layer to improve security
  • 36. Copyright Š 2002 ProsoftTraining. All rights reserved. Lesson 6: Inter-Servlet Communication
  • 37. Objectives • Share data with another servlet • Handle a single request using multiple servlets
  • 38. Sharing Data • Data-sharing methods of the ServletContext interface • Sharing data with another ServletContext
  • 39. Dispatching to Another Servlet • The forward method • The include method
  • 40. Summary  Share data with another servlet  Handle a single request using multiple servlets
  • 41. Copyright Š 2002 ProsoftTraining. All rights reserved. Lesson 7: Building Enterprise Web Applications
  • 42. Objectives • Use JNDI to look up EJBs, resource factories and environment entries • Write servlets for use in a distributed environment • Use JavaMail to send e-mail
  • 43. Java Servlets and JNDI • Referencing EJBs • Referencing resource factories • Referencing environment entries
  • 44. Clustering and Java Servlets • Clustering styles • Developing distributable servlets
  • 45. JavaMail • Add-on API that creates a full-fledged POP/iMAP client – Session class – getDefaultInstance static method
  • 46. Summary  Use JNDI to look up EJBs, resource factories and environment entries  Write servlets for use in a distributed environment  Use JavaMail to send e-mail
  • 47. Copyright Š 2002 ProsoftTraining. All rights reserved. Lesson 8: Internationalization
  • 48. Objectives • Use the Unicode escape sequence to specify special Latin characters • Use alternative character sets to generate a non-Latin character response
  • 49. The Latin Character Set • Non-English Latin characters • Languages and language codes
  • 50. Non-Latin Character Sets • Arabic • Chinese • Japanese • Korean • Russian
  • 51. Summary  Use the Unicode escape sequence to specify special Latin characters  Use alternative character sets to generate a non-Latin character response
  • 52. Java Servlets  Introduction to Java Servlets  The Servlet Life Cycle  Responding to a Request  Servlet Sessions  Authentication and Security  Inter-Servlet Communication  Building Enterprise Web Applications  Internationalization