Download presentation
Presentation is loading. Please wait.
1
J2EE Lecture 1:Servlet and JSP
Dr. Ming Qiu Xiamen University Software School
2
1. Preliminary Topics What do Web Server and Client do?
HTML and HTTP GET and POST URL What will Web Server not do ?
3
1.1 What do Web Server and Client do?
Head First to Servlets and JSP, Chap 01 1.1 What do Web Server and Client do?
4
1.1.1 HTML and HTTP HTML- HyperText Markup Language
Head First to Servlets and JSP, Chap 01 1.1.1 HTML and HTTP HTML- HyperText Markup Language Web Server often send the browser a set of instructions written in HTML. Tells the browser how to present the content to the user HTTP – HyperText Transport Protocol Allows for simple request and response conversation. The client sends an HTTP request. The Server answers with an HTTP response.
5
Head First to Servlets and JSP, Chap 01
1.1.1 HTML and HTTP
6
Head First to Servlets and JSP, Chap 01
1.1.2 GET and POST
7
1.1.3 Uniform Resource Locators
Head First to Servlets and JSP, Chap 01 1.1.3 Uniform Resource Locators
8
Head First to Servlets and JSP, Chap 01
Type a URL The browser create an HTTP GET request The HTTP GET is sent to the server And generates an HTTP response The server finds the page The browser rends HTML The response is sent to the browser
9
1.2 What will Web Server alone not do?
Head First to Servlets and JSP, Chap 01 1.2 What will Web Server alone not do? Dynamic Content Saving the Data on the Server
10
2. Servlets Introduction Interface Servlet and HttpServlet
11
2.1Introduction Servlets and Java Server Pages (JSP)
Java How to Program, Fifth Edition, Chap 24 2.1Introduction Servlets and Java Server Pages (JSP) Request-response model Packages javax.servlet javax.servlet.http javax.servlet.jsp javax.servlet.tagext Form the Web tier of J2EE
12
2.1Introduction Servlets under control of a container
Java How to Program, Fifth Edition, Chap 24 2.1Introduction Servlets under control of a container
13
2.1 Introduction Servlet Request/response mechanism
Head First to Servlets and JSP, Chap 02 2.1 Introduction Servlet Request/response mechanism
14
2.1 Introduction What does the container do? Communications support
Head First to Servlets and JSP, Chap 02 2.1 Introduction What does the container do? Communications support Lifecycle Management Multithread Support Declarative security JSP Support
15
2.1 Introduction How the Container handles a request
Head First to Servlets and JSP, Chap 02 2.1 Introduction How the Container handles a request
16
Head First to Servlets and JSP, Chap 02
2.1 Introduction
17
Head First to Servlets and JSP, Chap 02
2.1 Introduction
18
Java How to Program, Fifth Edition, Chap 24
19
Java How to Program, Fifth Edition, Chap 24
2.1 Introduction
20
Java How to Program, Fifth Edition, Chap 24
2.1 Introduction
21
Java How to Program, Fifth Edition, Chap 24
2.1 Introduction
22
2.2 Interface Servlet and HttpServlet
Java How to Program, Fifth Edition, Chap 24 2.2 Interface Servlet and HttpServlet Interface Servlet All servlets must implement this interface All methods of interface Servlet are invoked by servlet container GenericServlet and HttpServlet
23
2.2 Interface Servlet and HttpServlet
Java How to Program, Fifth Edition, Chap 24 2.2 Interface Servlet and HttpServlet Overrides method service Two most common HTTP request types get requests post requests Method doGet responds to get requests Method doPost responds to post requests HttpServletRequest and HttpServletResponse objects
24
2.2 Interface Servlet and HttpServlet
Java How to Program, Fifth Edition, Chap 24 2.2 Interface Servlet and HttpServlet HttpServletRequest Interface
25
2.2 Interface Servlet and HttpServlet
Java How to Program, Fifth Edition, Chap 24 2.2 Interface Servlet and HttpServlet HttpServletResponse Interface
26
Handling HTTP get Requests Containing Data
Java How to Program, Fifth Edition, Chap 24 Handling HTTP get Requests Containing Data
27
2.2 Interface Servlet and HttpServlet
Java How to Program, Fifth Edition, Chap 24 2.2 Interface Servlet and HttpServlet
28
2.2 Interface Servlet and HttpServlet
Java How to Program, Fifth Edition, Chap 24 2.2 Interface Servlet and HttpServlet
29
Handling HTTP post Requests Containing Data
Java How to Program, Fifth Edition, Chap 24 Handling HTTP post Requests Containing Data
30
2.2 Interface Servlet and HttpServlet
Java How to Program, Fifth Edition, Chap 24 2.2 Interface Servlet and HttpServlet
31
2.2 Interface Servlet and HttpServlet
Java How to Program, Fifth Edition, Chap 24 2.2 Interface Servlet and HttpServlet
32
3. JSP JavaServer Pages Reuse existing Java components
Java How to Program, Fifth Edition, Chap 25 3. JSP JavaServer Pages Extension of Servlet technology Reuse existing Java components Without programming Java Create custom tags Encapsulate complex functionality Classes and interfaces specific to JSP Package javax.servlet.jsp Package javax.servlet.jsp.tagext
33
Java How to Program, Fifth Edition, Chap 25
3. JSP
34
Java How to Program, Fifth Edition, Chap 25
3. JSP
35
3. JSP In the end, JSP is just a servlet
Head First to Servlets and JSP, Chap 07 3. JSP In the end, JSP is just a servlet
36
3 JSP JSPs Servlets Used when content is mostly fixed-template data
Java How to Program, Fifth Edition, Chap 25 3 JSP JSPs Used when content is mostly fixed-template data Small amounts of content generated dynamically Servlets Used when small amount of content is fixed-template data Most content generated dynamically
37
3. JSP Custom Tag Library JSP’s tag extension mechanism
Java How to Program, Fifth Edition, Chap 25 3. JSP Custom Tag Library JSP’s tag extension mechanism Enables programmers to define new tags Tags encapsulate complex functionality, written in java code Keep java code out of the pages.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.