Sunteți pe pagina 1din 62

SERVLET BASICS

Ging vin: Nguyn Hong Anh Email: nhanh@fit.hcmus.edu.vn

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Bi ging c trch t
http://www.javapassion.com/j2ee/ http://courses.coreservlets.com/CourseMaterials/csajsp2.html

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Contents
1

Servlet Servlet Request & Response Servlet Life Cycle Scope Object
CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

J2EE Architecture (1.2)

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Servlet
Client Side Presentation
HTML SERVLET Java Applet JSP HIBERNATE MySQL

Server Side Presentation

Database Access
JDBC

DBMS

SQL Server

Java Application

EJB,

DB2,

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Servlet Code

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Servlet Request & Response

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Request & Response

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

HTTP GET & HTTP POST

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

First Servlet

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Servlet Interfaces & Classes

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Servlet Life-Cycle

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Servlet Life-Cycle Methods

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Servlet Life-Cycle Methods

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Servlet Life-Cycle Methods

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

init() from CatalogServlet.java

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

init() reading Configuration parameters

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Setting Init Parameters in web.xml

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

destroy

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Servlet Life-Cycle Methods

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

service & doGet , doPost

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Service()

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

doGet() & doPost()

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

doGet()

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

doGet()

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

doGet()

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Steps of Populating HTTP Response

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Response

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Scope Objects

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Four Scope Objects: Accessibility

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Four Scope Objects: Class

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Scope Objects

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

What is ServletContext For?

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Scope of ServletContext

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

ServletContext: Web Application Scope

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

How to Access ServletContext Object?

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Example: Getting Attribute Value from ServletContext

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Example: Getting and Using RequestDispatcher Object

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Example: Logging

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Why HttpSession?

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

How to Get HttpSession?

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Example: HttpSession

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

What is Servlet Request?

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Session

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Request

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Getting Client Sent Parameters

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

A Sample FORM using GET

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

A Sample FORM using GET

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

A FORM Based Servlet: Get

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

A Sample FORM using POST

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

A Sample FORM using POST

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

A Form Based Servlet: POST

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

What is HTTP Servlet Request?

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

HTTP Request URL

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

HTTP Request URL:[requestpath]

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

HTTP Request URL: [query string]

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Context, Path, Query, Parameter

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Cookie Method (in HTTPServletRequest)

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Page, Request

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

What is Servlet Response?

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Responses

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

Response Structure

CNPM Web - KHTN Introduction to the SemanticCNTT Tutorial

S-ar putea să vă placă și