Unformatted text preview:

CS6320 Why Servlets L Grewe 1 What is a Servlet Servlets are Java programs that can be run dynamically from a Web Server Servlets are a server side technology A Servlet is an intermediating layer between an HTTP request of a client and the Web server 2 What is a Servlet Java s answer to the Common Gateway Interface CGI Applet a java program that runs within the web browser Servlet a java program that runs within the web server One standard for building web applications 3 A Java Servlet request request response response Servlet Servlet Web browser Web server 4 What do Servlets do Read data sent by the user e g form data Look up other information about the request in the HTTP request e g authentication data cookies etc Generate the result may do this by talking to a database file system etc Format the result in a document e g make it into HTML Set the appropriate HTTP response parameters e g cookies content type etc Send the document to the user 5 Some example applications Search Engines Personalization Systems E Commerce Applications Shopping Carts Product Catalogs Intranet Applications Groupware Applications bulletin boards file sharing etc 6 Other Server Side Options Mod Perl ASP PHP Cold Fusion Python NET More 7 Common Features All server side frameworks share a common set of features Read data submitted by the user Generate output dynamically based on user input Determine information about the client e g browser etc Access Database systems Exploit the HTTP protocol 8 Option CGI scripting Represents one of the earliest practical methods for generating web content Primarily written in the Perl programming language Unfortunately traditional CGI programs suffer from scalability and performance problems Let s examine these two problems 9 CGI 1 2 3 Browser initiates request Web server receives the request For each request web server spawns a new operating system process to execute the CGI Perl Program Web Browser Web Server Create New process Perl CGI 10 Problem SCALE For each browser request the web server must spawn a new operating system process Perl 1 Browser 1 Browser 2 Web Server Perl 2 Browser N Perl N 11 CGI Scripting Spawning a new operating system process for each request takes time and memory Hence traditional CGI programs have inherent performance and scalability problems Every other server architecture tries to address these problems 12 Option Mod Perl A module of the Apache Web Server Embeds the Perl interpreter directly within the web server Because Perl is embedded within the Server Mod Perl does not need to create a new process for each request Mod Perl is much faster than traditional CGI For more information see http perl apache org 13 Option ASP Active Server Pages Runs on Microsoft s Web Server Internet Information Server IIS Programmers add ASP code directly into their HTML pages When a client requests a page the Web Server takes the HTML page runs the ASP code within the page and returns a complete HTML page Faster than traditional CGI but only works on Microsoft IIS 14 Option Cold Fusion Developed by Allaire Corporation now owned by Macromedia Provides excellent database access and database tools Great platform for rapid prototyping and rapid development For more information http www macromedia com 15 Option PHP An open source project written entirely by volunteers Provides simple but powerful database access Also great for rapid development For additional information http www php net 16 Decision Points When evaluating which server side framework to use you need to consider a number of critical factors Ease of development How easily can you build new applications Performance How fast can the framework respond to queries Scalability Can the framework scale to thousands millions of users Security Are there any inherent security vulnerabilities 17 Advantages of Servlets Very clean elegant interface Built in Security Fast Performance Object Oriented Exception Handling Cross Platform Scalable to very large audiences 18 Advantages of Servlets Servlets have six main advantages Efficient Convenient Powerful Portable Secure Inexpensive 19 Servlet Efficient For each browser request the servlet spawns a light weight thread This is faster and more efficient that spawning a new operating system process Hence servlets have better performance and better scalability than traditional CGI 20 Servlet Convenient Servlets include built in functionality for Reading HTML form data Handling cookies Tracking user sessions Setting HTTP headers Java is object oriented 21 Servlet Powerful Servlets can talk directly to the web servers Multiple servlets can share data Particularly important for maintaining database connections Includes powerful techniques for tracking user sessions 22 Servlet Portable One of the advantages of Java is its portability across different operating systems Servlets have the same advantages You can therefore write your servlets on Windows then deploy them on UNIX You can also run any of your servlets on any Java enabled web server with no code changes 23 Servlet Secure Traditional CGI programs have a number of known security vulnerabilities Hence you usually need to include a separate Perl CGI module to supply the necessary security protection Java has a number of built in security layers Hence servlets are considered more secure than traditional CGI programs 24 Servlet Inexpensive You can download free servlet kits for development use You can therefore get started for free Nonetheless production strength servlet web servers can get quite expensive 25 Why Not Run in container more management complexity debugging Performance dependent on container Psuedo compiled speed compared to compiled programs Everything an object overhead 26


View Full Document

Cal State East Bay CS 6320 - WhyServlets

Loading Unlocking...
Login

Join to view WhyServlets and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view WhyServlets and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?