1. Module 04 – Java Servlets
Danairat T.
Line ID: Danairat
FB: Danairat Thanabodithammachari
+668-1559-1446
2. JEE and Web Application Development
The Course Outline
Module 01 - Introduction to JEE
Module 02 - The JEE Containers
Module 03 - The Model-View-Controller Design Pattern
Module 04 - Java Servlets
Module 05 - Java Server Pages in MVC
Module 06 - JEE Web Application Deployment
Module 07 - Enterprise Java Bean
Module 08 - JEE Enterprise Application Deployment
3. Java Servlets
Java programming language class
that is used the capabilities of
servers that host applications
accessed by means of a request-
response programming model.
The javax.servlet and
javax.servlet.http packages provide
interfaces and classes for writing
servlets.
The HttpServlet class provides
methods, such as doGet and
doPost, for handling HTTP-specific
services.
6. Variable Scopes
Application Scope
Session Scope
Request
Scope
Create in Servlet or JSP and retrieve the attributes
by only next target Servlet or JSP
Create in Servlet or JSP and retrieve the
attributes by Servlet or JSP until
• Servlet/JSP activate session invalidation
• User close Web Browser
Initial attributes by the Application Server
and retrieve the attributes by Servlet or JSP
until Servlet shutdown
43. Hands-on Lab: Servlets and HTTP Session Handling
Getting HTTP Session
20. Make change to the code by adding the HTTP session retrieval
44. Hands-on Lab: Servlets and HTTP Session Handling
Getting HTTP Session
21.Click “Run” from the “Servlet_SetHTTPSession”
45. Hands-on Lab: Servlets and HTTP Session Handling
Getting HTTP Session
22. Done execute adding properties to HTTP Session
46. Hands-on Lab: Servlets and HTTP Session Handling
Getting HTTP Session
23. Retrieve the session from other servlet “servlet_gethttpsession”
47. Hands-on Lab: Servlets and HTTP Session Handling
Getting HTTP Session
23. (Optional) Test access the Servlet_GetHTTPSession before the set HTTP Session
49. Hands-on Lab: Servlets invalidate the HTTP Session
1. Click “New” from “ViewController” project
by using the previous Application workspace 2. Select “HTTPServlet”
50. Hands-on Lab: Servlets invalidate the HTTP Session
3. Enter Servlet Name 4. Click “Finish”