Software Elements of Electronic Business Sites Daniel A. Menascé, Ph. D. www.cs.gmu.edu/faculty/menasce.html 1 Implementation Options Client Server Client-side: client-side scripts Java applets Server-side: CGI servlets -side scripts Fast CGI Web browser API 2 1
Client-Side: Applets Client Server <HTML><HEAD></HEAD> <BODY> <H1>My Applet</H1><BR> <APPLET CODE=MyApplet.class WIDTH=250 HEIGHT=25> </APPLET> </BODY> </HTML> Code class for applet assumed to be in the same directory as HTML page. 3 Client-Side: Applets Client Server 1. The browser requests the applet code from the. 2. The applet is executed by the browser in its JVM. 4 2
Running Applications at the Server: CGI Scripts Application new process created and killed after execution. If the app is written in Java a new JVM has to be started each time. good isolation and security stateless application 5 HTML Forms Application at (e.g., C executable, Perl script) <FORM ACTION= http://someserver/cgi-bin/myapplication > <INPUT TYPE= text NAME= keyword VALUE= books > <INPUT TYPE= submit NAME= submit VALUE= Go > </FORM> variable passed to application at default value of variable passed to Application at CGI: Common Gateway Interface 6 3
CGI Directories How does the knows that a request is for the execution of an application as opposed to a request to retrieve a static file? One can tell the Web where the CGI applications are and one can even alias the directory. In Apache: ScriptAlias /cgi-bin/ /home/~menasce/cgibin 7 Running Applications at the Server: Servlets Servlet Engine (e.g., Jserv, Jrun) Application (servlet) The Servlet engine loads a class in the JVM process and creates an instance of the Servlet class (at engine startup or at first request to Servlet). The same Servlet handles all requests (need to provide synchronization for access to global variables). 8 4
Running Applications at the Server: Servlets Servlet Engine (e.g., Jserv, Jrun) Application (servlet) Jserv: download from http://java.apache.org/ Needs Java Servlet Development Kit: http://java.sun.com 9 Running Applications at the Server: Server APIs application runs in the same context as poor isolation and security statefull applications easy to implement Application 10 5
CGI scripts vs. API: performance impact 25 Server Throughput (req/sec) 20 15 10 5 20.0 14.3 time to create/destroy cgiprocess= 40% time to execute application. 0 0 1 2 3 4 5 6 7 8 9 10 11 12 1314 15 16 17 1819 20 21 22 2324 25 26 27 2829 30 Number of Concurrent Requests CGIscripts Server-side scripting 11 Running Applications at the Server: Fast CGI TCP or IPC Application persistent process good isolation and security statefull applications easier to implement 12 6
Running Applications at the Server: Server Side Scripting 2 1,6 5 3 script script interpreter 4 generated page 13 Application Server Implementation Options CGI scripts (e.g., to process HTML forms) A new process is started for each request. Stateless application. Server APIs (e.g., NSAPI, ISAPI) Application code is loaded and executed in the same context as the. Poor security and no isolation. FastCGI Web and application communicate via light weight TCP or local IPC. Application can be persistent and statefull 14 7
Application Server Implementation Options (cont d) Server-side scripting Server interprets scripts or programs embedded in pages before returning them to the client: MS Active Server Pages (ASP) permits the use of JavaScript and VBScript combined with ActiveX controls written in any programming language. Netscape s LiveWire permits the use of -side JavaScript. 15 Implementation Options Client Server What are the relative advantages and disadvantages of client-side vs. -side computing in electronic commerce? 16 8