SlideShare a Scribd company logo
Outline
Introduction
Overview
WEB 1.0 vs WEB 2.0
HTTP, CGI, Web Application Model
HTTP
Common Gateway Interface (CGI)
Web Application Model
Summary
Servlet & JSP
Servlet
Java Server Pages
AJAX
Using AJAX
Summary
Resources
Java Web Application Model
Web Server
Database
Server Side Apps
Web Application Container
Web Application
/app1
servlet
servlet
servlet
Web Application
/app2
servlet
servlet
servlet
Server side Service Invocation
request
handling
client
request/response
Figure: Java Web Application Model
Java Web Application Model
There are several levels of scope, where each one has its
parameters:
I Container: system-wide configuration
I Application: application configuration and parameters
I Servlet: servlet information and parameters
I Page: information related with a JSP
I Session: session information can cross pages and servlets,
session can be used to store objects
Each level is modeled by a Java class or interface. (Implicit objects
in JSP)
Interface javax.servlet.Servlet
This interface defines methods to initialize a servlet, to service
requests, and to remove a servlet from the server:
I The servlet is constructed, then initialized with the init
method.
I Any calls from clients to the service method are handled.
I The servlet is taken out of service, then destroyed with the
destroy method, then garbage collected and finalized.
In addition to the life-cycle methods, this interface provides the
getServletConfig method, which the servlet can use to get any
startup information, and the getServletInfo method, which allows
the servlet to return basic information about itself, such as author,
version, and copyright.
Abstract Class javax.servlet.GenericServlet
The abstract class GenericServlet defines a generic,
protocol-independent servlet.
I It implements the Servlet and ServletConfig interface.
I It provides simple versions of the lifecycle methods init and
destroy and of the methods in the ServletConfig interface.
GenericServlet also implements the log method, declared in
the ServletContext interface.
To write a generic servlet, you need only override the abstract
service method. HttpServlet is a subclass of GenericServlet using
HTTP protocol.
Abstract class javax.servlet.http.HttpServlet
The abstract class HttpServlet is designed to be subclassed to
create an HTTP servlet suitable for a Web site. A subclass of
HttpServlet must override at least one method, usually one of
these:
I doGet, if the servlet supports HTTP GET requests
I doPost, for HTTP POST requests
I doPut, for HTTP PUT requests
I doDelete, for HTTP DELETE requests
I init and destroy, to manage resources that are held for the life
of the servlet
I getServletInfo, which the servlet uses to provide information
about itself
Abstract class javax.servlet.http.HttpServlet
The abstract class HttpServlet is designed to be subclassed to
create an HTTP servlet suitable for a Web site. A subclass of
HttpServlet must override at least one method, usually one of
these:
I doGet, if the servlet supports HTTP GET requests
I doPost, for HTTP POST requests
I doPut, for HTTP PUT requests
I doDelete, for HTTP DELETE requests
I init and destroy, to manage resources that are held for the life
of the servlet
I getServletInfo, which the servlet uses to provide information
about itself
Abstract class javax.servlet.http.HttpServlet
The abstract class HttpServlet is designed to be subclassed to
create an HTTP servlet suitable for a Web site. A subclass of
HttpServlet must override at least one method, usually one of
these:
I doGet, if the servlet supports HTTP GET requests
I doPost, for HTTP POST requests
I doPut, for HTTP PUT requests
I doDelete, for HTTP DELETE requests
I init and destroy, to manage resources that are held for the life
of the servlet
I getServletInfo, which the servlet uses to provide information
about itself
Abstract class javax.servlet.http.HttpServlet
The abstract class HttpServlet is designed to be subclassed to
create an HTTP servlet suitable for a Web site. A subclass of
HttpServlet must override at least one method, usually one of
these:
I doGet, if the servlet supports HTTP GET requests
I doPost, for HTTP POST requests
I doPut, for HTTP PUT requests
I doDelete, for HTTP DELETE requests
I init and destroy, to manage resources that are held for the life
of the servlet
I getServletInfo, which the servlet uses to provide information
about itself
Abstract class javax.servlet.http.HttpServlet
The abstract class HttpServlet is designed to be subclassed to
create an HTTP servlet suitable for a Web site. A subclass of
HttpServlet must override at least one method, usually one of
these:
I doGet, if the servlet supports HTTP GET requests
I doPost, for HTTP POST requests
I doPut, for HTTP PUT requests
I doDelete, for HTTP DELETE requests
I init and destroy, to manage resources that are held for the life
of the servlet
I getServletInfo, which the servlet uses to provide information
about itself
Abstract class javax.servlet.http.HttpServlet
The abstract class HttpServlet is designed to be subclassed to
create an HTTP servlet suitable for a Web site. A subclass of
HttpServlet must override at least one method, usually one of
these:
I doGet, if the servlet supports HTTP GET requests
I doPost, for HTTP POST requests
I doPut, for HTTP PUT requests
I doDelete, for HTTP DELETE requests
I init and destroy, to manage resources that are held for the life
of the servlet
I getServletInfo, which the servlet uses to provide information
about itself
Writing a HttpServlet
A Servlet which returns ”Hello World” to the browser
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("Hello World");
}
public String getServletInfo() {
return "Hello world example for PINFO";
}
}
Writing a HttpServlet II
Return HTML content
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html"); // set HTTP response content type
PrintWriter out = response.getWriter();
out.println("<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 " +
"Transitional//EN">n" +
"<HTML>n" +
"<HEAD><TITLE>Hello WWW</TITLE></HEAD>n" +
"<BODY>n" +
"<H1>Hello WWW</H1>n" +
"</BODY></HTML>");
}
public String getServletInfo() {
return "Hello world example for PINFO";
}
}
Get the value of the request parameter
HttpServletRequest class
Request URL: http://localhost:8080/list.jsp?category=pinfo05
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ... {
...
String cat = request.getParameter("category");
...}
cat will have value ”pinfo05”. It works for both GET and POST requests.
Two important classes: HttpServletRequest contains information
about the request; HttpServletResponse is used to generate HTTP
response.
Java Server Pages
Java Server Pages
A way of creating dynamic pages with Java and HTML.
Principle: Java for application logic, HTML for presentation.
JSP uses HTML for page rendering, and provides several ways to
use Java components:
I Scriptlet: Java codes enclosed by <% and %>
I Taglib: customized JSP tags
I Using JavaBeans
JSP are translated into Java servlets before they are compiled by
the Web application container. HttpServletRequest and
HttpServletResponse are implicit objects in JSP.
Implicit Objects in Java Server Page
The following variables can be directly used in JSP:
I page: jsp.HttpJspPage : Page’s servlet instance
I config: ServletConfig : Servlet configuration information
I pageContext: jsp.pageContext : Provides access to all the
namespaces associated with a JSP page and access to several
page attributes
I request: http.HttpServletRequest : Data included with the
HTTP Request
I response: http.HttpServletResponse : HTTP Response data,
e.g. cookies
I out: jsp.JspWriter : Output stream for page context
I session: http.HttpSession : User specific session data
I application: ServletContext : Data shared by all application
pages
Implicit Objects in Java Server Page
The following variables can be directly used in JSP:
I page: jsp.HttpJspPage : Page’s servlet instance
I config: ServletConfig : Servlet configuration information
I pageContext: jsp.pageContext : Provides access to all the
namespaces associated with a JSP page and access to several
page attributes
I request: http.HttpServletRequest : Data included with the
HTTP Request
I response: http.HttpServletResponse : HTTP Response data,
e.g. cookies
I out: jsp.JspWriter : Output stream for page context
I session: http.HttpSession : User specific session data
I application: ServletContext : Data shared by all application
pages
Implicit Objects in Java Server Page
The following variables can be directly used in JSP:
I page: jsp.HttpJspPage : Page’s servlet instance
I config: ServletConfig : Servlet configuration information
I pageContext: jsp.pageContext : Provides access to all the
namespaces associated with a JSP page and access to several
page attributes
I request: http.HttpServletRequest : Data included with the
HTTP Request
I response: http.HttpServletResponse : HTTP Response data,
e.g. cookies
I out: jsp.JspWriter : Output stream for page context
I session: http.HttpSession : User specific session data
I application: ServletContext : Data shared by all application
pages
Implicit Objects in Java Server Page
The following variables can be directly used in JSP:
I page: jsp.HttpJspPage : Page’s servlet instance
I config: ServletConfig : Servlet configuration information
I pageContext: jsp.pageContext : Provides access to all the
namespaces associated with a JSP page and access to several
page attributes
I request: http.HttpServletRequest : Data included with the
HTTP Request
I response: http.HttpServletResponse : HTTP Response data,
e.g. cookies
I out: jsp.JspWriter : Output stream for page context
I session: http.HttpSession : User specific session data
I application: ServletContext : Data shared by all application
pages
Implicit Objects in Java Server Page
The following variables can be directly used in JSP:
I page: jsp.HttpJspPage : Page’s servlet instance
I config: ServletConfig : Servlet configuration information
I pageContext: jsp.pageContext : Provides access to all the
namespaces associated with a JSP page and access to several
page attributes
I request: http.HttpServletRequest : Data included with the
HTTP Request
I response: http.HttpServletResponse : HTTP Response data,
e.g. cookies
I out: jsp.JspWriter : Output stream for page context
I session: http.HttpSession : User specific session data
I application: ServletContext : Data shared by all application
pages
Implicit Objects in Java Server Page
The following variables can be directly used in JSP:
I page: jsp.HttpJspPage : Page’s servlet instance
I config: ServletConfig : Servlet configuration information
I pageContext: jsp.pageContext : Provides access to all the
namespaces associated with a JSP page and access to several
page attributes
I request: http.HttpServletRequest : Data included with the
HTTP Request
I response: http.HttpServletResponse : HTTP Response data,
e.g. cookies
I out: jsp.JspWriter : Output stream for page context
I session: http.HttpSession : User specific session data
I application: ServletContext : Data shared by all application
pages
Implicit Objects in Java Server Page
The following variables can be directly used in JSP:
I page: jsp.HttpJspPage : Page’s servlet instance
I config: ServletConfig : Servlet configuration information
I pageContext: jsp.pageContext : Provides access to all the
namespaces associated with a JSP page and access to several
page attributes
I request: http.HttpServletRequest : Data included with the
HTTP Request
I response: http.HttpServletResponse : HTTP Response data,
e.g. cookies
I out: jsp.JspWriter : Output stream for page context
I session: http.HttpSession : User specific session data
I application: ServletContext : Data shared by all application
pages
Implicit Objects in Java Server Page
The following variables can be directly used in JSP:
I page: jsp.HttpJspPage : Page’s servlet instance
I config: ServletConfig : Servlet configuration information
I pageContext: jsp.pageContext : Provides access to all the
namespaces associated with a JSP page and access to several
page attributes
I request: http.HttpServletRequest : Data included with the
HTTP Request
I response: http.HttpServletResponse : HTTP Response data,
e.g. cookies
I out: jsp.JspWriter : Output stream for page context
I session: http.HttpSession : User specific session data
I application: ServletContext : Data shared by all application
pages
Outline
Introduction
Overview
WEB 1.0 vs WEB 2.0
HTTP, CGI, Web Application Model
HTTP
Common Gateway Interface (CGI)
Web Application Model
Summary
Servlet & JSP
Servlet
Java Server Pages
AJAX
Using AJAX
Summary
Resources
Asynchronous JavaScript And XML (AJAX)
AJAX incorporates several technologies:
I standards-based presentation using XHTML and CSS;
I dynamic display and interaction using the Document Object
Model;
I data interchange and manipulation using XML and XSLT;
I asynchronous data retrieval using XMLHttpRequest;
I and JavaScript binding everything together.
www.w3schools.com provides tutorials for XHTML, CSS, DOM,
XML, AJAX, JavaScript etc.
Asynchronous JavaScript And XML (AJAX)
AJAX incorporates several technologies:
I standards-based presentation using XHTML and CSS;
I dynamic display and interaction using the Document Object
Model;
I data interchange and manipulation using XML and XSLT;
I asynchronous data retrieval using XMLHttpRequest;
I and JavaScript binding everything together.
www.w3schools.com provides tutorials for XHTML, CSS, DOM,
XML, AJAX, JavaScript etc.
Asynchronous JavaScript And XML (AJAX)
AJAX incorporates several technologies:
I standards-based presentation using XHTML and CSS;
I dynamic display and interaction using the Document Object
Model;
I data interchange and manipulation using XML and XSLT;
I asynchronous data retrieval using XMLHttpRequest;
I and JavaScript binding everything together.
www.w3schools.com provides tutorials for XHTML, CSS, DOM,
XML, AJAX, JavaScript etc.
Asynchronous JavaScript And XML (AJAX)
AJAX incorporates several technologies:
I standards-based presentation using XHTML and CSS;
I dynamic display and interaction using the Document Object
Model;
I data interchange and manipulation using XML and XSLT;
I asynchronous data retrieval using XMLHttpRequest;
I and JavaScript binding everything together.
www.w3schools.com provides tutorials for XHTML, CSS, DOM,
XML, AJAX, JavaScript etc.
Asynchronous JavaScript And XML (AJAX)
AJAX incorporates several technologies:
I standards-based presentation using XHTML and CSS;
I dynamic display and interaction using the Document Object
Model;
I data interchange and manipulation using XML and XSLT;
I asynchronous data retrieval using XMLHttpRequest;
I and JavaScript binding everything together.
www.w3schools.com provides tutorials for XHTML, CSS, DOM,
XML, AJAX, JavaScript etc.
AJAX: Connect HTML with JavaScript
Capture Events on HTML pages
I Mouse event (with elements): mouse down, mouse up, mouse
move, mouse over ...
I Keyboard event: key pressed ...
I Form: submitted ...
I Timer etc.
Example: Call the getListByCategory function when the mouse is
moved over the hyper linked text, and call the function cleanTable
when the moused is moved out the link.
<a href="/" onmouseover="getListByCategory()"
onmouseout="clearTable()">Show Member List</a>
AJAX: Create XMLHttpRequest Object
This function will create an XMLHttpRequest object and send a GET
request to the server page http://pinfo.unige.ch:8080/Member/list.jsp
with parameter category with value pinfo05.
Send a HTTP request via XMLHttpRequest Object:
function getListByCategory() {
var req = false;
var self = this;
var url = "http://pinfo.unige.ch:8080/Member/list.jsp?category=pinfo05";
if (window.XMLHttpRequest) {
self.req = new XMLHttpRequest(); // for Firefox and other browsers
} else if (window.ActiveXObject) {
self.req = new ActiveXObject("Microsoft.XMLHTTP"); // for IE browser
}
// when the request is finished, call this function
self.req.onreadystatechange = processRequest;
self.req.open("GET", url, true); // it is a GET request
self.req.send(null); // send the request
}
Note that the implementation of XMLHttpRequest is different from one
browser to another.
AJAX: Handling Asynchronous Response
A node is tagged with id ”result” in the HTML document
<div id=result></div>
The function processRequest is called when the XMLHttpRequest
is finished (asynchronous response).
function processRequest() {
// check the request state is "complete"
if (req.readyState == 4 || req.readyState == "complete") {
if (req.status == 200) {
updatepage(self.req.responseText);
} else {
alert("Not able to retrieve member list");
}
}
}
// Just set the content of note with id "result" with the input parameter
// Other DOM and XML operations are possible, here it is simplified.
function updatepage(str) {
document.getElementById("result").innerHTML = str;
}
AJAX: Web Application Model
Figure: AJAX Web Application Model
AJAX: Interactions
Figure: AJAX Interactions
Outline
Introduction
Overview
WEB 1.0 vs WEB 2.0
HTTP, CGI, Web Application Model
HTTP
Common Gateway Interface (CGI)
Web Application Model
Summary
Servlet & JSP
Servlet
Java Server Pages
AJAX
Using AJAX
Summary
Resources
Summary
I Web Application Model: relations between client, Web server,
server side application, and web application. The Application
Container model is mature.
I JSP and Servlets provide server side programming facilities:
reusability, manageability, security etc.
I AJAX provides a standard solution for client/server
interaction: XML based, Asynchronous, no page refresh
needed. It is the most used technology in WEB 2.0.
I AJAX is the complement for the presentation layer of Web
applications with JSP: JSP provides services, AJAX use these
services, messages are in XML, communication via HTTP.
I WEB 2.0 is more than AJAX.
Summary
I Web Application Model: relations between client, Web server,
server side application, and web application. The Application
Container model is mature.
I JSP and Servlets provide server side programming facilities:
reusability, manageability, security etc.
I AJAX provides a standard solution for client/server
interaction: XML based, Asynchronous, no page refresh
needed. It is the most used technology in WEB 2.0.
I AJAX is the complement for the presentation layer of Web
applications with JSP: JSP provides services, AJAX use these
services, messages are in XML, communication via HTTP.
I WEB 2.0 is more than AJAX.
Summary
I Web Application Model: relations between client, Web server,
server side application, and web application. The Application
Container model is mature.
I JSP and Servlets provide server side programming facilities:
reusability, manageability, security etc.
I AJAX provides a standard solution for client/server
interaction: XML based, Asynchronous, no page refresh
needed. It is the most used technology in WEB 2.0.
I AJAX is the complement for the presentation layer of Web
applications with JSP: JSP provides services, AJAX use these
services, messages are in XML, communication via HTTP.
I WEB 2.0 is more than AJAX.
Summary
I Web Application Model: relations between client, Web server,
server side application, and web application. The Application
Container model is mature.
I JSP and Servlets provide server side programming facilities:
reusability, manageability, security etc.
I AJAX provides a standard solution for client/server
interaction: XML based, Asynchronous, no page refresh
needed. It is the most used technology in WEB 2.0.
I AJAX is the complement for the presentation layer of Web
applications with JSP: JSP provides services, AJAX use these
services, messages are in XML, communication via HTTP.
I WEB 2.0 is more than AJAX.
Summary
I Web Application Model: relations between client, Web server,
server side application, and web application. The Application
Container model is mature.
I JSP and Servlets provide server side programming facilities:
reusability, manageability, security etc.
I AJAX provides a standard solution for client/server
interaction: XML based, Asynchronous, no page refresh
needed. It is the most used technology in WEB 2.0.
I AJAX is the complement for the presentation layer of Web
applications with JSP: JSP provides services, AJAX use these
services, messages are in XML, communication via HTTP.
I WEB 2.0 is more than AJAX.
Summary
I Web Application Model: relations between client, Web server,
server side application, and web application. The Application
Container model is mature.
I JSP and Servlets provide server side programming facilities:
reusability, manageability, security etc.
I AJAX provides a standard solution for client/server
interaction: XML based, Asynchronous, no page refresh
needed. It is the most used technology in WEB 2.0.
I AJAX is the complement for the presentation layer of Web
applications with JSP: JSP provides services, AJAX use these
services, messages are in XML, communication via HTTP.
I WEB 2.0 is more than AJAX.
Outline
Introduction
Overview
WEB 1.0 vs WEB 2.0
HTTP, CGI, Web Application Model
HTTP
Common Gateway Interface (CGI)
Web Application Model
Summary
Servlet & JSP
Servlet
Java Server Pages
AJAX
Using AJAX
Summary
Resources
Servlet, JSP
Specifications:
I Java Servlet Specifications
I JSP Technology
Tutorial:
I Basic Servlets:
http://www.apl.jhu.edu/ hall/java/Servlet-Tutorial/
I MoreServlets Book & Tutorials: Servlet, JSP, Taglib, Struts,
AJAX
AJAX, WEB 2.0
AJAX:
I Ajax: A New Approach to Web Applications
I AJAX: Getting Started, mozilla developer center
I Top 10 Ajax Applications
I AJAX Tutorial
I AJAX Login System Demo
I Guide to Using AJAX and XMLHttpRequest
I Ajaxian
WEB 2.0
I O’Reilly: What Is Web 2.0
I The Best Web 2.0 Software of 2005
I Writly
I Google Earth
Ad

More Related Content

Similar to HTTP, JSP, and AJAX.pdf (20)

Basics Of Servlet
Basics Of ServletBasics Of Servlet
Basics Of Servlet
Shubhani Jain
 
Chap4 4 1
Chap4 4 1Chap4 4 1
Chap4 4 1
Hemo Chella
 
Knowledge Sharing : Java Servlet
Knowledge Sharing : Java ServletKnowledge Sharing : Java Servlet
Knowledge Sharing : Java Servlet
Fahmi Jafar
 
Servlets
ServletsServlets
Servlets
Sasidhar Kothuru
 
1 java servlets and jsp
1   java servlets and jsp1   java servlets and jsp
1 java servlets and jsp
Ankit Minocha
 
Java servlets
Java servletsJava servlets
Java servlets
yuvarani p
 
Servlets intro
Servlets introServlets intro
Servlets intro
vantinhkhuc
 
WEB TECHNOLOGIES Servlet
WEB TECHNOLOGIES ServletWEB TECHNOLOGIES Servlet
WEB TECHNOLOGIES Servlet
Jyothishmathi Institute of Technology and Science Karimnagar
 
UNIT-3 Servlet
UNIT-3 ServletUNIT-3 Servlet
UNIT-3 Servlet
ssbd6985
 
SERVLETS (2).pptxintroduction to servlet with all servlets
SERVLETS (2).pptxintroduction to servlet with all servletsSERVLETS (2).pptxintroduction to servlet with all servlets
SERVLETS (2).pptxintroduction to servlet with all servlets
RadhikaP41
 
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B KuteJava Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Tushar B Kute
 
Servlet in java , java servlet , servlet servlet and CGI, API
Servlet in java , java servlet , servlet servlet and CGI, APIServlet in java , java servlet , servlet servlet and CGI, API
Servlet in java , java servlet , servlet servlet and CGI, API
PRIYADARSINISK
 
J2ee servlet
J2ee servletJ2ee servlet
J2ee servlet
vinoth ponnurangam
 
Java Web Programming [2/9] : Servlet Basic
Java Web Programming [2/9] : Servlet BasicJava Web Programming [2/9] : Servlet Basic
Java Web Programming [2/9] : Servlet Basic
IMC Institute
 
Servlet ppt by vikas jagtap
Servlet ppt by vikas jagtapServlet ppt by vikas jagtap
Servlet ppt by vikas jagtap
Vikas Jagtap
 
Servlet by Rj
Servlet by RjServlet by Rj
Servlet by Rj
Shree M.L.Kakadiya MCA mahila college, Amreli
 
JAVA Servlets
JAVA ServletsJAVA Servlets
JAVA Servlets
deepak kumar
 
Unitwwsbdsbsdbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb-4.pptx
Unitwwsbdsbsdbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb-4.pptxUnitwwsbdsbsdbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb-4.pptx
Unitwwsbdsbsdbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb-4.pptx
VikasTuwar1
 
SERVLET in web technolgy engineering.pptx
SERVLET in web technolgy engineering.pptxSERVLET in web technolgy engineering.pptx
SERVLET in web technolgy engineering.pptx
ARUNKUMARM230658
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
Ahmed Madkor
 
Knowledge Sharing : Java Servlet
Knowledge Sharing : Java ServletKnowledge Sharing : Java Servlet
Knowledge Sharing : Java Servlet
Fahmi Jafar
 
1 java servlets and jsp
1   java servlets and jsp1   java servlets and jsp
1 java servlets and jsp
Ankit Minocha
 
UNIT-3 Servlet
UNIT-3 ServletUNIT-3 Servlet
UNIT-3 Servlet
ssbd6985
 
SERVLETS (2).pptxintroduction to servlet with all servlets
SERVLETS (2).pptxintroduction to servlet with all servletsSERVLETS (2).pptxintroduction to servlet with all servlets
SERVLETS (2).pptxintroduction to servlet with all servlets
RadhikaP41
 
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B KuteJava Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Tushar B Kute
 
Servlet in java , java servlet , servlet servlet and CGI, API
Servlet in java , java servlet , servlet servlet and CGI, APIServlet in java , java servlet , servlet servlet and CGI, API
Servlet in java , java servlet , servlet servlet and CGI, API
PRIYADARSINISK
 
Java Web Programming [2/9] : Servlet Basic
Java Web Programming [2/9] : Servlet BasicJava Web Programming [2/9] : Servlet Basic
Java Web Programming [2/9] : Servlet Basic
IMC Institute
 
Servlet ppt by vikas jagtap
Servlet ppt by vikas jagtapServlet ppt by vikas jagtap
Servlet ppt by vikas jagtap
Vikas Jagtap
 
Unitwwsbdsbsdbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb-4.pptx
Unitwwsbdsbsdbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb-4.pptxUnitwwsbdsbsdbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb-4.pptx
Unitwwsbdsbsdbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb-4.pptx
VikasTuwar1
 
SERVLET in web technolgy engineering.pptx
SERVLET in web technolgy engineering.pptxSERVLET in web technolgy engineering.pptx
SERVLET in web technolgy engineering.pptx
ARUNKUMARM230658
 

More from Arumugam90 (20)

Type Script notes for Data Structures using java
Type Script notes for Data Structures using javaType Script notes for Data Structures using java
Type Script notes for Data Structures using java
Arumugam90
 
Data Structures using java notes for MCA
Data Structures using java notes for MCAData Structures using java notes for MCA
Data Structures using java notes for MCA
Arumugam90
 
Progressive Web Application Development for MCA
Progressive Web Application Development for MCAProgressive Web Application Development for MCA
Progressive Web Application Development for MCA
Arumugam90
 
Notes for AR.ppt
Notes for AR.pptNotes for AR.ppt
Notes for AR.ppt
Arumugam90
 
Unity Tutorial_Highlighted Notes.pdf
Unity Tutorial_Highlighted Notes.pdfUnity Tutorial_Highlighted Notes.pdf
Unity Tutorial_Highlighted Notes.pdf
Arumugam90
 
AUGMENTED REALITY.pptx
AUGMENTED REALITY.pptxAUGMENTED REALITY.pptx
AUGMENTED REALITY.pptx
Arumugam90
 
Introductiontokaryotyping.pptx
Introductiontokaryotyping.pptxIntroductiontokaryotyping.pptx
Introductiontokaryotyping.pptx
Arumugam90
 
ML
MLML
ML
Arumugam90
 
intro.ppt
intro.pptintro.ppt
intro.ppt
Arumugam90
 
Unit I_Computer Networks_2.ppt
Unit I_Computer Networks_2.pptUnit I_Computer Networks_2.ppt
Unit I_Computer Networks_2.ppt
Arumugam90
 
Unit_I_Computer Networks 4.pdf
Unit_I_Computer Networks 4.pdfUnit_I_Computer Networks 4.pdf
Unit_I_Computer Networks 4.pdf
Arumugam90
 
CS3114_09212011.ppt
CS3114_09212011.pptCS3114_09212011.ppt
CS3114_09212011.ppt
Arumugam90
 
Chapter16.ppt
Chapter16.pptChapter16.ppt
Chapter16.ppt
Arumugam90
 
Chapter15.ppt
Chapter15.pptChapter15.ppt
Chapter15.ppt
Arumugam90
 
JSP Components and Directives.pdf
JSP Components and Directives.pdfJSP Components and Directives.pdf
JSP Components and Directives.pdf
Arumugam90
 
JSP.pdf
JSP.pdfJSP.pdf
JSP.pdf
Arumugam90
 
Java Servlets.pdf
Java Servlets.pdfJava Servlets.pdf
Java Servlets.pdf
Arumugam90
 
JDBC with MySQL.pdf
JDBC with MySQL.pdfJDBC with MySQL.pdf
JDBC with MySQL.pdf
Arumugam90
 
JDBC with MySQL.pdf
JDBC with MySQL.pdfJDBC with MySQL.pdf
JDBC with MySQL.pdf
Arumugam90
 
JDBC.pdf
JDBC.pdfJDBC.pdf
JDBC.pdf
Arumugam90
 
Type Script notes for Data Structures using java
Type Script notes for Data Structures using javaType Script notes for Data Structures using java
Type Script notes for Data Structures using java
Arumugam90
 
Data Structures using java notes for MCA
Data Structures using java notes for MCAData Structures using java notes for MCA
Data Structures using java notes for MCA
Arumugam90
 
Progressive Web Application Development for MCA
Progressive Web Application Development for MCAProgressive Web Application Development for MCA
Progressive Web Application Development for MCA
Arumugam90
 
Notes for AR.ppt
Notes for AR.pptNotes for AR.ppt
Notes for AR.ppt
Arumugam90
 
Unity Tutorial_Highlighted Notes.pdf
Unity Tutorial_Highlighted Notes.pdfUnity Tutorial_Highlighted Notes.pdf
Unity Tutorial_Highlighted Notes.pdf
Arumugam90
 
AUGMENTED REALITY.pptx
AUGMENTED REALITY.pptxAUGMENTED REALITY.pptx
AUGMENTED REALITY.pptx
Arumugam90
 
Introductiontokaryotyping.pptx
Introductiontokaryotyping.pptxIntroductiontokaryotyping.pptx
Introductiontokaryotyping.pptx
Arumugam90
 
Unit I_Computer Networks_2.ppt
Unit I_Computer Networks_2.pptUnit I_Computer Networks_2.ppt
Unit I_Computer Networks_2.ppt
Arumugam90
 
Unit_I_Computer Networks 4.pdf
Unit_I_Computer Networks 4.pdfUnit_I_Computer Networks 4.pdf
Unit_I_Computer Networks 4.pdf
Arumugam90
 
CS3114_09212011.ppt
CS3114_09212011.pptCS3114_09212011.ppt
CS3114_09212011.ppt
Arumugam90
 
JSP Components and Directives.pdf
JSP Components and Directives.pdfJSP Components and Directives.pdf
JSP Components and Directives.pdf
Arumugam90
 
Java Servlets.pdf
Java Servlets.pdfJava Servlets.pdf
Java Servlets.pdf
Arumugam90
 
JDBC with MySQL.pdf
JDBC with MySQL.pdfJDBC with MySQL.pdf
JDBC with MySQL.pdf
Arumugam90
 
JDBC with MySQL.pdf
JDBC with MySQL.pdfJDBC with MySQL.pdf
JDBC with MySQL.pdf
Arumugam90
 
Ad

Recently uploaded (20)

Language Learning App Data Research by Globibo [2025]
Language Learning App Data Research by Globibo [2025]Language Learning App Data Research by Globibo [2025]
Language Learning App Data Research by Globibo [2025]
globibo
 
最新版澳洲西澳大利亚大学毕业证(UWA毕业证书)原版定制
最新版澳洲西澳大利亚大学毕业证(UWA毕业证书)原版定制最新版澳洲西澳大利亚大学毕业证(UWA毕业证书)原版定制
最新版澳洲西澳大利亚大学毕业证(UWA毕业证书)原版定制
Taqyea
 
Important JavaScript Concepts Every Developer Must Know
Important JavaScript Concepts Every Developer Must KnowImportant JavaScript Concepts Every Developer Must Know
Important JavaScript Concepts Every Developer Must Know
yashikanigam1
 
Bringing data to life - Crime webinar Accessible.pptx
Bringing data to life - Crime webinar Accessible.pptxBringing data to life - Crime webinar Accessible.pptx
Bringing data to life - Crime webinar Accessible.pptx
Office for National Statistics
 
presentacion.slideshare.informáticaJuridica..pptx
presentacion.slideshare.informáticaJuridica..pptxpresentacion.slideshare.informáticaJuridica..pptx
presentacion.slideshare.informáticaJuridica..pptx
GersonVillatoro4
 
national income & related aggregates (1)(1).pptx
national income & related aggregates (1)(1).pptxnational income & related aggregates (1)(1).pptx
national income & related aggregates (1)(1).pptx
j2492618
 
Publication-launch-How-is-Life-for-Children-in-the-Digital-Age-15-May-2025.pdf
Publication-launch-How-is-Life-for-Children-in-the-Digital-Age-15-May-2025.pdfPublication-launch-How-is-Life-for-Children-in-the-Digital-Age-15-May-2025.pdf
Publication-launch-How-is-Life-for-Children-in-the-Digital-Age-15-May-2025.pdf
StatsCommunications
 
web-roadmap developer file information..
web-roadmap developer file information..web-roadmap developer file information..
web-roadmap developer file information..
pandeyarush01
 
lecture_13 tree in mmmmmmmm mmmmmfftro.pptx
lecture_13 tree in mmmmmmmm     mmmmmfftro.pptxlecture_13 tree in mmmmmmmm     mmmmmfftro.pptx
lecture_13 tree in mmmmmmmm mmmmmfftro.pptx
sarajafffri058
 
Hootsuite Social Trends 2025 Report_en.pdf
Hootsuite Social Trends 2025 Report_en.pdfHootsuite Social Trends 2025 Report_en.pdf
Hootsuite Social Trends 2025 Report_en.pdf
lionardoadityabagask
 
Kilowatt's Impact Report _ 2024 x
Kilowatt's Impact Report _ 2024                xKilowatt's Impact Report _ 2024                x
Kilowatt's Impact Report _ 2024 x
Kilowatt
 
Digital Disruption Use Case_Music Industry_for students.pdf
Digital Disruption Use Case_Music Industry_for students.pdfDigital Disruption Use Case_Music Industry_for students.pdf
Digital Disruption Use Case_Music Industry_for students.pdf
ProsenjitMitra9
 
Concrete_Presenbmlkvvbvvvfvbbbfcfftation.pptx
Concrete_Presenbmlkvvbvvvfvbbbfcfftation.pptxConcrete_Presenbmlkvvbvvvfvbbbfcfftation.pptx
Concrete_Presenbmlkvvbvvvfvbbbfcfftation.pptx
ssuserd1f4a3
 
Lesson 6-Interviewing in SHRM_updated.pdf
Lesson 6-Interviewing in SHRM_updated.pdfLesson 6-Interviewing in SHRM_updated.pdf
Lesson 6-Interviewing in SHRM_updated.pdf
hemelali11
 
Red Hat Openshift Training - openshift (1).pptx
Red Hat Openshift Training - openshift (1).pptxRed Hat Openshift Training - openshift (1).pptx
Red Hat Openshift Training - openshift (1).pptx
ssuserf60686
 
Introduction to Artificial Intelligence_ Lec 2
Introduction to Artificial Intelligence_ Lec 2Introduction to Artificial Intelligence_ Lec 2
Introduction to Artificial Intelligence_ Lec 2
Dalal2Ali
 
End to End Process Analysis - Cox Communications
End to End Process Analysis - Cox CommunicationsEnd to End Process Analysis - Cox Communications
End to End Process Analysis - Cox Communications
Process mining Evangelist
 
CS-404 COA COURSE FILE JAN JUN 2025.docx
CS-404 COA COURSE FILE JAN JUN 2025.docxCS-404 COA COURSE FILE JAN JUN 2025.docx
CS-404 COA COURSE FILE JAN JUN 2025.docx
nidarizvitit
 
Time series analysis & forecasting-Day1.pptx
Time series analysis & forecasting-Day1.pptxTime series analysis & forecasting-Day1.pptx
Time series analysis & forecasting-Day1.pptx
AsmaaMahmoud89
 
Feature Engineering for Electronic Health Record Systems
Feature Engineering for Electronic Health Record SystemsFeature Engineering for Electronic Health Record Systems
Feature Engineering for Electronic Health Record Systems
Process mining Evangelist
 
Language Learning App Data Research by Globibo [2025]
Language Learning App Data Research by Globibo [2025]Language Learning App Data Research by Globibo [2025]
Language Learning App Data Research by Globibo [2025]
globibo
 
最新版澳洲西澳大利亚大学毕业证(UWA毕业证书)原版定制
最新版澳洲西澳大利亚大学毕业证(UWA毕业证书)原版定制最新版澳洲西澳大利亚大学毕业证(UWA毕业证书)原版定制
最新版澳洲西澳大利亚大学毕业证(UWA毕业证书)原版定制
Taqyea
 
Important JavaScript Concepts Every Developer Must Know
Important JavaScript Concepts Every Developer Must KnowImportant JavaScript Concepts Every Developer Must Know
Important JavaScript Concepts Every Developer Must Know
yashikanigam1
 
presentacion.slideshare.informáticaJuridica..pptx
presentacion.slideshare.informáticaJuridica..pptxpresentacion.slideshare.informáticaJuridica..pptx
presentacion.slideshare.informáticaJuridica..pptx
GersonVillatoro4
 
national income & related aggregates (1)(1).pptx
national income & related aggregates (1)(1).pptxnational income & related aggregates (1)(1).pptx
national income & related aggregates (1)(1).pptx
j2492618
 
Publication-launch-How-is-Life-for-Children-in-the-Digital-Age-15-May-2025.pdf
Publication-launch-How-is-Life-for-Children-in-the-Digital-Age-15-May-2025.pdfPublication-launch-How-is-Life-for-Children-in-the-Digital-Age-15-May-2025.pdf
Publication-launch-How-is-Life-for-Children-in-the-Digital-Age-15-May-2025.pdf
StatsCommunications
 
web-roadmap developer file information..
web-roadmap developer file information..web-roadmap developer file information..
web-roadmap developer file information..
pandeyarush01
 
lecture_13 tree in mmmmmmmm mmmmmfftro.pptx
lecture_13 tree in mmmmmmmm     mmmmmfftro.pptxlecture_13 tree in mmmmmmmm     mmmmmfftro.pptx
lecture_13 tree in mmmmmmmm mmmmmfftro.pptx
sarajafffri058
 
Hootsuite Social Trends 2025 Report_en.pdf
Hootsuite Social Trends 2025 Report_en.pdfHootsuite Social Trends 2025 Report_en.pdf
Hootsuite Social Trends 2025 Report_en.pdf
lionardoadityabagask
 
Kilowatt's Impact Report _ 2024 x
Kilowatt's Impact Report _ 2024                xKilowatt's Impact Report _ 2024                x
Kilowatt's Impact Report _ 2024 x
Kilowatt
 
Digital Disruption Use Case_Music Industry_for students.pdf
Digital Disruption Use Case_Music Industry_for students.pdfDigital Disruption Use Case_Music Industry_for students.pdf
Digital Disruption Use Case_Music Industry_for students.pdf
ProsenjitMitra9
 
Concrete_Presenbmlkvvbvvvfvbbbfcfftation.pptx
Concrete_Presenbmlkvvbvvvfvbbbfcfftation.pptxConcrete_Presenbmlkvvbvvvfvbbbfcfftation.pptx
Concrete_Presenbmlkvvbvvvfvbbbfcfftation.pptx
ssuserd1f4a3
 
Lesson 6-Interviewing in SHRM_updated.pdf
Lesson 6-Interviewing in SHRM_updated.pdfLesson 6-Interviewing in SHRM_updated.pdf
Lesson 6-Interviewing in SHRM_updated.pdf
hemelali11
 
Red Hat Openshift Training - openshift (1).pptx
Red Hat Openshift Training - openshift (1).pptxRed Hat Openshift Training - openshift (1).pptx
Red Hat Openshift Training - openshift (1).pptx
ssuserf60686
 
Introduction to Artificial Intelligence_ Lec 2
Introduction to Artificial Intelligence_ Lec 2Introduction to Artificial Intelligence_ Lec 2
Introduction to Artificial Intelligence_ Lec 2
Dalal2Ali
 
End to End Process Analysis - Cox Communications
End to End Process Analysis - Cox CommunicationsEnd to End Process Analysis - Cox Communications
End to End Process Analysis - Cox Communications
Process mining Evangelist
 
CS-404 COA COURSE FILE JAN JUN 2025.docx
CS-404 COA COURSE FILE JAN JUN 2025.docxCS-404 COA COURSE FILE JAN JUN 2025.docx
CS-404 COA COURSE FILE JAN JUN 2025.docx
nidarizvitit
 
Time series analysis & forecasting-Day1.pptx
Time series analysis & forecasting-Day1.pptxTime series analysis & forecasting-Day1.pptx
Time series analysis & forecasting-Day1.pptx
AsmaaMahmoud89
 
Feature Engineering for Electronic Health Record Systems
Feature Engineering for Electronic Health Record SystemsFeature Engineering for Electronic Health Record Systems
Feature Engineering for Electronic Health Record Systems
Process mining Evangelist
 
Ad

HTTP, JSP, and AJAX.pdf

  • 1. Outline Introduction Overview WEB 1.0 vs WEB 2.0 HTTP, CGI, Web Application Model HTTP Common Gateway Interface (CGI) Web Application Model Summary Servlet & JSP Servlet Java Server Pages AJAX Using AJAX Summary Resources
  • 2. Java Web Application Model Web Server Database Server Side Apps Web Application Container Web Application /app1 servlet servlet servlet Web Application /app2 servlet servlet servlet Server side Service Invocation request handling client request/response Figure: Java Web Application Model
  • 3. Java Web Application Model There are several levels of scope, where each one has its parameters: I Container: system-wide configuration I Application: application configuration and parameters I Servlet: servlet information and parameters I Page: information related with a JSP I Session: session information can cross pages and servlets, session can be used to store objects Each level is modeled by a Java class or interface. (Implicit objects in JSP)
  • 4. Interface javax.servlet.Servlet This interface defines methods to initialize a servlet, to service requests, and to remove a servlet from the server: I The servlet is constructed, then initialized with the init method. I Any calls from clients to the service method are handled. I The servlet is taken out of service, then destroyed with the destroy method, then garbage collected and finalized. In addition to the life-cycle methods, this interface provides the getServletConfig method, which the servlet can use to get any startup information, and the getServletInfo method, which allows the servlet to return basic information about itself, such as author, version, and copyright.
  • 5. Abstract Class javax.servlet.GenericServlet The abstract class GenericServlet defines a generic, protocol-independent servlet. I It implements the Servlet and ServletConfig interface. I It provides simple versions of the lifecycle methods init and destroy and of the methods in the ServletConfig interface. GenericServlet also implements the log method, declared in the ServletContext interface. To write a generic servlet, you need only override the abstract service method. HttpServlet is a subclass of GenericServlet using HTTP protocol.
  • 6. Abstract class javax.servlet.http.HttpServlet The abstract class HttpServlet is designed to be subclassed to create an HTTP servlet suitable for a Web site. A subclass of HttpServlet must override at least one method, usually one of these: I doGet, if the servlet supports HTTP GET requests I doPost, for HTTP POST requests I doPut, for HTTP PUT requests I doDelete, for HTTP DELETE requests I init and destroy, to manage resources that are held for the life of the servlet I getServletInfo, which the servlet uses to provide information about itself
  • 7. Abstract class javax.servlet.http.HttpServlet The abstract class HttpServlet is designed to be subclassed to create an HTTP servlet suitable for a Web site. A subclass of HttpServlet must override at least one method, usually one of these: I doGet, if the servlet supports HTTP GET requests I doPost, for HTTP POST requests I doPut, for HTTP PUT requests I doDelete, for HTTP DELETE requests I init and destroy, to manage resources that are held for the life of the servlet I getServletInfo, which the servlet uses to provide information about itself
  • 8. Abstract class javax.servlet.http.HttpServlet The abstract class HttpServlet is designed to be subclassed to create an HTTP servlet suitable for a Web site. A subclass of HttpServlet must override at least one method, usually one of these: I doGet, if the servlet supports HTTP GET requests I doPost, for HTTP POST requests I doPut, for HTTP PUT requests I doDelete, for HTTP DELETE requests I init and destroy, to manage resources that are held for the life of the servlet I getServletInfo, which the servlet uses to provide information about itself
  • 9. Abstract class javax.servlet.http.HttpServlet The abstract class HttpServlet is designed to be subclassed to create an HTTP servlet suitable for a Web site. A subclass of HttpServlet must override at least one method, usually one of these: I doGet, if the servlet supports HTTP GET requests I doPost, for HTTP POST requests I doPut, for HTTP PUT requests I doDelete, for HTTP DELETE requests I init and destroy, to manage resources that are held for the life of the servlet I getServletInfo, which the servlet uses to provide information about itself
  • 10. Abstract class javax.servlet.http.HttpServlet The abstract class HttpServlet is designed to be subclassed to create an HTTP servlet suitable for a Web site. A subclass of HttpServlet must override at least one method, usually one of these: I doGet, if the servlet supports HTTP GET requests I doPost, for HTTP POST requests I doPut, for HTTP PUT requests I doDelete, for HTTP DELETE requests I init and destroy, to manage resources that are held for the life of the servlet I getServletInfo, which the servlet uses to provide information about itself
  • 11. Abstract class javax.servlet.http.HttpServlet The abstract class HttpServlet is designed to be subclassed to create an HTTP servlet suitable for a Web site. A subclass of HttpServlet must override at least one method, usually one of these: I doGet, if the servlet supports HTTP GET requests I doPost, for HTTP POST requests I doPut, for HTTP PUT requests I doDelete, for HTTP DELETE requests I init and destroy, to manage resources that are held for the life of the servlet I getServletInfo, which the servlet uses to provide information about itself
  • 12. Writing a HttpServlet A Servlet which returns ”Hello World” to the browser import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class HelloWorld extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); out.println("Hello World"); } public String getServletInfo() { return "Hello world example for PINFO"; } }
  • 13. Writing a HttpServlet II Return HTML content import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class HelloWorld extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); // set HTTP response content type PrintWriter out = response.getWriter(); out.println("<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 " + "Transitional//EN">n" + "<HTML>n" + "<HEAD><TITLE>Hello WWW</TITLE></HEAD>n" + "<BODY>n" + "<H1>Hello WWW</H1>n" + "</BODY></HTML>"); } public String getServletInfo() { return "Hello world example for PINFO"; } }
  • 14. Get the value of the request parameter HttpServletRequest class Request URL: http://localhost:8080/list.jsp?category=pinfo05 public void doGet(HttpServletRequest request, HttpServletResponse response) throws ... { ... String cat = request.getParameter("category"); ...} cat will have value ”pinfo05”. It works for both GET and POST requests. Two important classes: HttpServletRequest contains information about the request; HttpServletResponse is used to generate HTTP response.
  • 15. Java Server Pages Java Server Pages A way of creating dynamic pages with Java and HTML. Principle: Java for application logic, HTML for presentation. JSP uses HTML for page rendering, and provides several ways to use Java components: I Scriptlet: Java codes enclosed by <% and %> I Taglib: customized JSP tags I Using JavaBeans JSP are translated into Java servlets before they are compiled by the Web application container. HttpServletRequest and HttpServletResponse are implicit objects in JSP.
  • 16. Implicit Objects in Java Server Page The following variables can be directly used in JSP: I page: jsp.HttpJspPage : Page’s servlet instance I config: ServletConfig : Servlet configuration information I pageContext: jsp.pageContext : Provides access to all the namespaces associated with a JSP page and access to several page attributes I request: http.HttpServletRequest : Data included with the HTTP Request I response: http.HttpServletResponse : HTTP Response data, e.g. cookies I out: jsp.JspWriter : Output stream for page context I session: http.HttpSession : User specific session data I application: ServletContext : Data shared by all application pages
  • 17. Implicit Objects in Java Server Page The following variables can be directly used in JSP: I page: jsp.HttpJspPage : Page’s servlet instance I config: ServletConfig : Servlet configuration information I pageContext: jsp.pageContext : Provides access to all the namespaces associated with a JSP page and access to several page attributes I request: http.HttpServletRequest : Data included with the HTTP Request I response: http.HttpServletResponse : HTTP Response data, e.g. cookies I out: jsp.JspWriter : Output stream for page context I session: http.HttpSession : User specific session data I application: ServletContext : Data shared by all application pages
  • 18. Implicit Objects in Java Server Page The following variables can be directly used in JSP: I page: jsp.HttpJspPage : Page’s servlet instance I config: ServletConfig : Servlet configuration information I pageContext: jsp.pageContext : Provides access to all the namespaces associated with a JSP page and access to several page attributes I request: http.HttpServletRequest : Data included with the HTTP Request I response: http.HttpServletResponse : HTTP Response data, e.g. cookies I out: jsp.JspWriter : Output stream for page context I session: http.HttpSession : User specific session data I application: ServletContext : Data shared by all application pages
  • 19. Implicit Objects in Java Server Page The following variables can be directly used in JSP: I page: jsp.HttpJspPage : Page’s servlet instance I config: ServletConfig : Servlet configuration information I pageContext: jsp.pageContext : Provides access to all the namespaces associated with a JSP page and access to several page attributes I request: http.HttpServletRequest : Data included with the HTTP Request I response: http.HttpServletResponse : HTTP Response data, e.g. cookies I out: jsp.JspWriter : Output stream for page context I session: http.HttpSession : User specific session data I application: ServletContext : Data shared by all application pages
  • 20. Implicit Objects in Java Server Page The following variables can be directly used in JSP: I page: jsp.HttpJspPage : Page’s servlet instance I config: ServletConfig : Servlet configuration information I pageContext: jsp.pageContext : Provides access to all the namespaces associated with a JSP page and access to several page attributes I request: http.HttpServletRequest : Data included with the HTTP Request I response: http.HttpServletResponse : HTTP Response data, e.g. cookies I out: jsp.JspWriter : Output stream for page context I session: http.HttpSession : User specific session data I application: ServletContext : Data shared by all application pages
  • 21. Implicit Objects in Java Server Page The following variables can be directly used in JSP: I page: jsp.HttpJspPage : Page’s servlet instance I config: ServletConfig : Servlet configuration information I pageContext: jsp.pageContext : Provides access to all the namespaces associated with a JSP page and access to several page attributes I request: http.HttpServletRequest : Data included with the HTTP Request I response: http.HttpServletResponse : HTTP Response data, e.g. cookies I out: jsp.JspWriter : Output stream for page context I session: http.HttpSession : User specific session data I application: ServletContext : Data shared by all application pages
  • 22. Implicit Objects in Java Server Page The following variables can be directly used in JSP: I page: jsp.HttpJspPage : Page’s servlet instance I config: ServletConfig : Servlet configuration information I pageContext: jsp.pageContext : Provides access to all the namespaces associated with a JSP page and access to several page attributes I request: http.HttpServletRequest : Data included with the HTTP Request I response: http.HttpServletResponse : HTTP Response data, e.g. cookies I out: jsp.JspWriter : Output stream for page context I session: http.HttpSession : User specific session data I application: ServletContext : Data shared by all application pages
  • 23. Implicit Objects in Java Server Page The following variables can be directly used in JSP: I page: jsp.HttpJspPage : Page’s servlet instance I config: ServletConfig : Servlet configuration information I pageContext: jsp.pageContext : Provides access to all the namespaces associated with a JSP page and access to several page attributes I request: http.HttpServletRequest : Data included with the HTTP Request I response: http.HttpServletResponse : HTTP Response data, e.g. cookies I out: jsp.JspWriter : Output stream for page context I session: http.HttpSession : User specific session data I application: ServletContext : Data shared by all application pages
  • 24. Outline Introduction Overview WEB 1.0 vs WEB 2.0 HTTP, CGI, Web Application Model HTTP Common Gateway Interface (CGI) Web Application Model Summary Servlet & JSP Servlet Java Server Pages AJAX Using AJAX Summary Resources
  • 25. Asynchronous JavaScript And XML (AJAX) AJAX incorporates several technologies: I standards-based presentation using XHTML and CSS; I dynamic display and interaction using the Document Object Model; I data interchange and manipulation using XML and XSLT; I asynchronous data retrieval using XMLHttpRequest; I and JavaScript binding everything together. www.w3schools.com provides tutorials for XHTML, CSS, DOM, XML, AJAX, JavaScript etc.
  • 26. Asynchronous JavaScript And XML (AJAX) AJAX incorporates several technologies: I standards-based presentation using XHTML and CSS; I dynamic display and interaction using the Document Object Model; I data interchange and manipulation using XML and XSLT; I asynchronous data retrieval using XMLHttpRequest; I and JavaScript binding everything together. www.w3schools.com provides tutorials for XHTML, CSS, DOM, XML, AJAX, JavaScript etc.
  • 27. Asynchronous JavaScript And XML (AJAX) AJAX incorporates several technologies: I standards-based presentation using XHTML and CSS; I dynamic display and interaction using the Document Object Model; I data interchange and manipulation using XML and XSLT; I asynchronous data retrieval using XMLHttpRequest; I and JavaScript binding everything together. www.w3schools.com provides tutorials for XHTML, CSS, DOM, XML, AJAX, JavaScript etc.
  • 28. Asynchronous JavaScript And XML (AJAX) AJAX incorporates several technologies: I standards-based presentation using XHTML and CSS; I dynamic display and interaction using the Document Object Model; I data interchange and manipulation using XML and XSLT; I asynchronous data retrieval using XMLHttpRequest; I and JavaScript binding everything together. www.w3schools.com provides tutorials for XHTML, CSS, DOM, XML, AJAX, JavaScript etc.
  • 29. Asynchronous JavaScript And XML (AJAX) AJAX incorporates several technologies: I standards-based presentation using XHTML and CSS; I dynamic display and interaction using the Document Object Model; I data interchange and manipulation using XML and XSLT; I asynchronous data retrieval using XMLHttpRequest; I and JavaScript binding everything together. www.w3schools.com provides tutorials for XHTML, CSS, DOM, XML, AJAX, JavaScript etc.
  • 30. AJAX: Connect HTML with JavaScript Capture Events on HTML pages I Mouse event (with elements): mouse down, mouse up, mouse move, mouse over ... I Keyboard event: key pressed ... I Form: submitted ... I Timer etc. Example: Call the getListByCategory function when the mouse is moved over the hyper linked text, and call the function cleanTable when the moused is moved out the link. <a href="/" onmouseover="getListByCategory()" onmouseout="clearTable()">Show Member List</a>
  • 31. AJAX: Create XMLHttpRequest Object This function will create an XMLHttpRequest object and send a GET request to the server page http://pinfo.unige.ch:8080/Member/list.jsp with parameter category with value pinfo05. Send a HTTP request via XMLHttpRequest Object: function getListByCategory() { var req = false; var self = this; var url = "http://pinfo.unige.ch:8080/Member/list.jsp?category=pinfo05"; if (window.XMLHttpRequest) { self.req = new XMLHttpRequest(); // for Firefox and other browsers } else if (window.ActiveXObject) { self.req = new ActiveXObject("Microsoft.XMLHTTP"); // for IE browser } // when the request is finished, call this function self.req.onreadystatechange = processRequest; self.req.open("GET", url, true); // it is a GET request self.req.send(null); // send the request } Note that the implementation of XMLHttpRequest is different from one browser to another.
  • 32. AJAX: Handling Asynchronous Response A node is tagged with id ”result” in the HTML document <div id=result></div> The function processRequest is called when the XMLHttpRequest is finished (asynchronous response). function processRequest() { // check the request state is "complete" if (req.readyState == 4 || req.readyState == "complete") { if (req.status == 200) { updatepage(self.req.responseText); } else { alert("Not able to retrieve member list"); } } } // Just set the content of note with id "result" with the input parameter // Other DOM and XML operations are possible, here it is simplified. function updatepage(str) { document.getElementById("result").innerHTML = str; }
  • 33. AJAX: Web Application Model Figure: AJAX Web Application Model
  • 35. Outline Introduction Overview WEB 1.0 vs WEB 2.0 HTTP, CGI, Web Application Model HTTP Common Gateway Interface (CGI) Web Application Model Summary Servlet & JSP Servlet Java Server Pages AJAX Using AJAX Summary Resources
  • 36. Summary I Web Application Model: relations between client, Web server, server side application, and web application. The Application Container model is mature. I JSP and Servlets provide server side programming facilities: reusability, manageability, security etc. I AJAX provides a standard solution for client/server interaction: XML based, Asynchronous, no page refresh needed. It is the most used technology in WEB 2.0. I AJAX is the complement for the presentation layer of Web applications with JSP: JSP provides services, AJAX use these services, messages are in XML, communication via HTTP. I WEB 2.0 is more than AJAX.
  • 37. Summary I Web Application Model: relations between client, Web server, server side application, and web application. The Application Container model is mature. I JSP and Servlets provide server side programming facilities: reusability, manageability, security etc. I AJAX provides a standard solution for client/server interaction: XML based, Asynchronous, no page refresh needed. It is the most used technology in WEB 2.0. I AJAX is the complement for the presentation layer of Web applications with JSP: JSP provides services, AJAX use these services, messages are in XML, communication via HTTP. I WEB 2.0 is more than AJAX.
  • 38. Summary I Web Application Model: relations between client, Web server, server side application, and web application. The Application Container model is mature. I JSP and Servlets provide server side programming facilities: reusability, manageability, security etc. I AJAX provides a standard solution for client/server interaction: XML based, Asynchronous, no page refresh needed. It is the most used technology in WEB 2.0. I AJAX is the complement for the presentation layer of Web applications with JSP: JSP provides services, AJAX use these services, messages are in XML, communication via HTTP. I WEB 2.0 is more than AJAX.
  • 39. Summary I Web Application Model: relations between client, Web server, server side application, and web application. The Application Container model is mature. I JSP and Servlets provide server side programming facilities: reusability, manageability, security etc. I AJAX provides a standard solution for client/server interaction: XML based, Asynchronous, no page refresh needed. It is the most used technology in WEB 2.0. I AJAX is the complement for the presentation layer of Web applications with JSP: JSP provides services, AJAX use these services, messages are in XML, communication via HTTP. I WEB 2.0 is more than AJAX.
  • 40. Summary I Web Application Model: relations between client, Web server, server side application, and web application. The Application Container model is mature. I JSP and Servlets provide server side programming facilities: reusability, manageability, security etc. I AJAX provides a standard solution for client/server interaction: XML based, Asynchronous, no page refresh needed. It is the most used technology in WEB 2.0. I AJAX is the complement for the presentation layer of Web applications with JSP: JSP provides services, AJAX use these services, messages are in XML, communication via HTTP. I WEB 2.0 is more than AJAX.
  • 41. Summary I Web Application Model: relations between client, Web server, server side application, and web application. The Application Container model is mature. I JSP and Servlets provide server side programming facilities: reusability, manageability, security etc. I AJAX provides a standard solution for client/server interaction: XML based, Asynchronous, no page refresh needed. It is the most used technology in WEB 2.0. I AJAX is the complement for the presentation layer of Web applications with JSP: JSP provides services, AJAX use these services, messages are in XML, communication via HTTP. I WEB 2.0 is more than AJAX.
  • 42. Outline Introduction Overview WEB 1.0 vs WEB 2.0 HTTP, CGI, Web Application Model HTTP Common Gateway Interface (CGI) Web Application Model Summary Servlet & JSP Servlet Java Server Pages AJAX Using AJAX Summary Resources
  • 43. Servlet, JSP Specifications: I Java Servlet Specifications I JSP Technology Tutorial: I Basic Servlets: http://www.apl.jhu.edu/ hall/java/Servlet-Tutorial/ I MoreServlets Book & Tutorials: Servlet, JSP, Taglib, Struts, AJAX
  • 44. AJAX, WEB 2.0 AJAX: I Ajax: A New Approach to Web Applications I AJAX: Getting Started, mozilla developer center I Top 10 Ajax Applications I AJAX Tutorial I AJAX Login System Demo I Guide to Using AJAX and XMLHttpRequest I Ajaxian WEB 2.0 I O’Reilly: What Is Web 2.0 I The Best Web 2.0 Software of 2005 I Writly I Google Earth
  翻译: