Applets & Servlets. 2 Overview This presentation will provide an overview of the basics of applets...
-
Upload
pearl-dorsey -
Category
Documents
-
view
214 -
download
0
Transcript of Applets & Servlets. 2 Overview This presentation will provide an overview of the basics of applets...
2
Overview This presentation will provide an overview of
the basics of applets and servlets as well as their roles in web development and enrichment. The presentation will answer the following questions:
What is an applet? How do applets work? What is a servlet? How do servlets work? What are the advantages and disadvantages of
servlets? Is there a relationship between applets and servlets?
3
What is an applet?
An applet is a Java program that is embedded and ran in some other Java interpreter program such as a Java technology-enabled
browser Sun’s applet viewer program
called appletviewer
5
How do applets work? Step 1
Download and install Sun’s Java Software Development Kit (SDK) to allow compilation and interpretation of compiled class files
Write the Java source code for the applet in any text editor.
6
How do applets work? Step 2
Compile the source code to obtain the necessary bytecodes known as “.class” for interpreting
7
How do applets work? Step 3
Web page
Server
httpserver
applet
image
HTML controls
client
clientWeb page
Web page
9
What is a servlet?
A servlet is a Java program that executes on the server side in a special secure environment, such as Inside servlet-support web servers Standalone servlet containers
10
What is a servlet? (Cont’d)
Commonly run inside a web server, servlets are dynamically loaded to extend the functionality of the server
Functionally, servlets are an alternative to CGI scripts for creating dynamic web content
11
Common Servlet Containers iPlanet (Netscape) Web Server
Enterprise Edition Zeus Web Server World Wide Web Consortium’s Jigsaw
Server Sun’s Java Web Server Apache’s Web Server via JServ
module Apache’s Tomcat Server ***
12
How do servlets works? Step 1
Download and install Sun’s Java Software Development Kit (SDK) to allow compilation and interpretation of compiled class files
Download and install servlet-support server
13
How do servlets work? Step 2
Write the Java source code for the applet in any text editor.
Compile the source code to obtain the necessary bytecodes known as “.class” for interpreting
15
How do servlets work?
Server
Apache’s WebServer
via JServ
Web page
applet
image
HTML controls
client
client
Port 80JServ Module
System Resources
Scenario 1: Web Server with built-in servlet support
16
How do servlets work? Scenario 2: Standalone Servlet Container
Server
Web page
applet
image
HTML controls
client
client
Any PortApache’s Tomcat Server
System Resources
Static Web page
17
Servlet Life Cycle
Main Process
JVM
Servlet1
Servlet2
Request for Servlet1
Request for Servlet1
Request for Servlet2
threadthread
thread
Java Servlet-based Web Server
22
What are the advantages of servlets? Portability
Portable across operating systems and across web servers
Power Harness the full power of the core Java
APIs: networking and URL access, multithreading, image manipulation, data compression, JDBC, object serialization, internationalization
23
What are the advantages of servlets? (Cont’d)
Efficiency & Endurance Memory resident, so invocation highly
efficient Safety
Support safe programming since inherit Java’s strong type safety, exception-handling mechanism
24
What are the advantages of servlets? (Cont’d)
Elegance Code is clean, object-oriented,
modular, and simple (i.e.. Session tracking, cookie)
Integration Tightly integrated with the server—
translate file paths, perform logging, check authorization, and MIME type mapping
25
What are the disadvantages of servlets?
Developers MUST know JAVA Web Administrator will need to
learn how to install and maintain Java Servlets
Tedious uses of out.println() statements Can be remedied by using Java Server
Page (JSP)
28
Is there a relationship between applets and servlets?
Technically, NO! Thought to be applet that runs on
the server side - without a face Effective in building client/server or
other networked applications
29
Browser
Applet/Servlet Model
Server
Web page
applet
image
HTML controls
client
Any PortServlet Engine
System Resources
Applet
Port 80
Any Port
HTML