Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
2Activity
0 of .
Results for:
No results containing your search query
P. 1
15Servelets

15Servelets

Ratings: (0)|Views: 83|Likes:
Published by vsunny_488

More info:

Published by: vsunny_488 on Sep 03, 2008
Copyright:Traditional Copyright: All rights reserved

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF or read online from Scribd
See more
See less

07/07/2010

 
CSIE33000 Net ProgrammingLecture11 Java ServeletShiow-yang WuNote 1
Lecture 15: Servelets
Based on Notes by Dave Hollinger & Ethan Cerami Also, the Online Java Tutorial by Sun
CSIE33000 Network ProgrammingServelets2
What is a Servlet?
 A Servletis a Java program that extends thecapabilities of servers.
Inherentlymulti-threaded.
Each request launches a new thread.
Input from client is automatically parsed into aRequest variable.
 A servletcan be thought of as a server-side applet
 Applet: a java program that runs within the web browser
Servlet: a java program that runs within the web server
Servletsare loaded and executed by a web server in thesame manner that applets are loaded and executed by aweb browser
 
CSIE33000 Net ProgrammingLecture11 Java ServeletShiow-yang WuNote 2
CSIE33000 Network ProgrammingServelets3
Server-Side Application
 Architecture
 Applications
Dynamic generates HTML pages
 Access to database and/or back-end servers
etc.
CSIE33000 Network ProgrammingServelets4
Server-Side Application: CGIs
Common Gateway Interface (CGI)
Basically call external program
Use standard input and output for data exchange
Programming language independent
Weakness
CGI program may not be easilyportable to other platform
Substantial overhead is incurredin starting the CGI process
 
CSIE33000 Net ProgrammingLecture11 Java ServeletShiow-yang WuNote 3
CSIE33000 Network ProgrammingServelets5
Servlet Architecture
The client makes a request via HTTP
The web server receives the requests and forwards it to theservlet
If the servlet has not yet been loaded, the web server loads it intothe JVM and executes it
The servlet receives the HTTP request and performs sometype of process
The servlet returns a response to the web server
The web server forwards the response to the client
Client(web browser)WebServer
HTTP requestHTTP response
ServletContainterServlet
CSIE33000 Network ProgrammingServelets6
Why Use Servlets
Servlets are designed to replace CGI scripts
Platform-independent and extensible
CGI scripts are typically written in Perlor C, and are very muchtied to a particular server platform
Servlet is written in Java, which can easily integrate with existinglegacy systems through RMI, CORBA, and/or JNI
Persistent and fast
Servers are loaded only once by the web server and can maintainservices between requests (particularly important for maintainingdatabase connections)
CGI scripts are transient –a CGI script is removed from memoryafter it is complete
For each browser request, the web server must spawn a newoperating system process
Secure
The only way to invoke a servlet from the outside world isthrough a web server, which can be protected behind a firewall

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->