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
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
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
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
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
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
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
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
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
48. Objectives
• Use the Unicode escape sequence to specify
special Latin characters
• Use alternative character sets to generate a
non-Latin character response
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