Download presentation
1
Server-side Technologies
Technologies that exist at the server side Where the real work occurs
2
Server-side Technologies
Looking at …. Client-side scripting v Server-side scripting Factors in selecting a technology Older and New technologies CGI, Fast CGI, Mod Perl, Active Server Pages (ASP), Cold Fusion Overview of Servlets Introduction to Java Server Pages (JSP)
3
Client-side scripting v Server-side scripting
Validates user input Accesses the browser Enhances Web pages with ActiveX® controls, applets, etc. Manipulates browser documents Client-side validation Reduces number of requests that need to be passed to server Client-side scripting limitations Browser dependency Viewable to users through View Source command JavaScript most popular client-side script
4
Client-side scripting v Server-side scripting
Server-side scripts Provides programmers greater flexibility Generates custom responses for clients Contains greater programmatic capabilities than client-side equivalents Has access to server-side software that extend server functionality
5
Server-side options Common Gateway Interface (CGI) Fast CGI Mod Perl
Active Server Pages (ASP) Personal Home Pages (PHP) Cold Fusion Java Servlets Java Server Page (JSP)
6
Common Features All server-side frameworks share a common set of features Read data submitted by the user Generate HTML dynamically based on user input Determine information about the client browser Access database systems Exploit the HTTP protocol
7
Decision Points When evaluating which server-side technology 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 technology respond to queries Scalability Can the technology scale to thousands, even millions of users? Security Are there any inherent security vulnerabilities?
8
Common Gateway Interface (CGI)
CGI represents one of the earliest, practical methods for generating web content Primarily written in the Perl programming language Unfortunately, some CGI programs suffer from scalability and performance problems Let us see why this happens
9
CGI Architecture Browser initiates request Web server receives request
For each new request, web server spawns a new operating system process to execute the CGI/Perl program Create new process Web Server Perl/CGI Browser
10
CGI Architecture For each browser request, the web server must spawn a new operating system process CGI/Perl 1 Browser 1 Web Server Browser 2 CGI/Perl 2 Browser N Create new process CGI/Perl N
11
CGI Architecture Spawning a new operating system process for each request takes time and memory Hence, CGI programs have inherent scalability and performance problems Almost all other server architectures address these problems
12
Fast CGI Developed by Open Market as an option for developing faster, more scalable CGI programs Works by creating a pool of processes for handling CGI requests When a server receives a CGI request, Fast CGI picks up one of the processes from the pool and assigns it to the task Without the overhead of creating new processes each time, Fast CGI is much quicker than traditional CGI
13
Mod Perl A module of the Apache Web server
Embeds the Perl interpreter directly within the web server Perl programs are therefore precompiled Since Perl is embedded within the server, Mod Perl does not need to create a new process for each request Like Fast CGI, Mod Perl is much faster than traditional CGI
14
Server Extensions Several web servers provide extension APIs (Application Programming Interfaces) Netscape provides (NSAPI) Microsoft provides (ISAPA) Similar to Mod Perl, these programs run directly within the web server Hence, Server Extensions are much faster than traditional CGI Usually written in C/C++, they are not portable across web servers E.g. if you develop using Netscape NSAPI, you cannot run it on Microsoft ISAPA
15
ASP (Active Server Pages)
Developed by Microsoft Runs on Microsoft’s web server: IIS (Internet Information Server) Developers add ASP code directly to 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 the result in another HTML page Faster than traditional CGI but only works with Microsoft’s IIS
16
Cold Fusion Developed by Allaire Corporation
Provides excellent database access and tools Very good technology for Rapid Prototyping and Rapid development
17
PHP (Personal Home Pages)
An open source project developed by volunteers Provides simple and powerful database access and tools Good for Rapid Application Development
18
Servlet Java’s answer to the CGI script
Do not confuse a servlet with an applet Applet: a java program that runs within a browser Servlet: a java program that runs within a web server Rapidly becoming most popular technology for developing web based applications
19
Servlet Overview Servlets are a significant development in client/server computing for the web Java Servlet API – standard extension to Java Provides a Java class that can be loaded dynamically to expand the functionality of a Java-enabled server Does not require Java support on the client side
20
Servlet Overview Provides a generic mechanism for extending the functionality of any kind of server (not just web servers) e.g. could be used to extend the functionality of a Java-based ftp server, or a mail server to scan for viruses attached to Makes it easier for applets to communicate with the server Created to solve one basic need recognised: Generating dynamic web content
21
History of Servlets In late 1996, the use of Java on the server side was developing Allows getting away from the use of sockets on the server side Software vendors were each developing their own approach Problem: each technology was tied to a particular vendor server program
22
History of Servlets Better to have a generic technology so that server programs could have the “write-once, run-anywhere” approach Early 1997, JavaSoft (Sun Microsystems) released the Servlet API Designed to work on Java and non-Java based servers Most web servers support Servlets
23
General mechanism Execute within the server’s process space
Each servlet handled by a separate thread within the server process, not as separate processes (as in CGI). Servlets are portable across different web servers and different operating systems Fast, powerful and portable replacements to CGI scripts
24
General mechanism Persist between invocations (CGI scripts reloaded), resulting in significant performance benefits over CGI programs Servlets have full access to the Java APIs and also to third party component classes (e.g. database connections, etc.)
25
Places where Servlets can be used
Accessed by name to generate a HTML page Embedded inside a HTML page as a server side include These are useful when a web page is mostly static info but contains small sections of dynamically-generated info Embedded inside a HTML page using Java Server Pages (JSP) – see these later
26
3 types of servlet engine
Standalone Server that contains built in support for Servlets (e.g. Tomcat) Does not exist for many web servers Disadvantage: have to wait for a new server release to get latest servlet support Add-on A plug-in for an existing web server Many have been written for servers (e.g. Apache) Embedded Lightweight servlet platform that can be embedded in another application
27
Advantages of Servlets
Servlets have 6 main advantages Efficient Convenient Powerful Portable Secure Inexpensive Let us see why
28
Advantages of Servlets
Efficient For each browser request, the servlet spawns a light weight thread This is faster and more efficient than spawning a new operating system process Hence, servlets have better performance and scalability than traditional CGI
29
Advantages of Servlets
Convenient Servlets include built-in functionality for: Reading HTML from data Handling cookies Tracking user sessions Setting HTTP headers Java is an object-oriented language which arguably can make development easier
30
Advantages of Servlets
Powerful Servlets can talk directly to web servers Multiple servlets can share data Particularly important for maintaining database connections Includes powerful techniques for tracking user sessions
31
Advantages of Servlets
Portable One of the advantages of Java is its portability across different operating systems Servlets have the same advantages (they are written in Java) Can be written on a Windows platform and run on a UNIX operating system Servlets can be run on any Java-enabled web server with no code changes
32
Advantages of Servlets
Secure Traditional CGI programs have a number of known security vulnerabilities Hence, a separate CGI/Perl script is usually required to provide the extra security required Java itself has a number of built-in security features Therefore, Servlets are regarded to be more secure than CGI programs
33
Advantages of Servlets
Inexpensive You can download free servlet kits for development As many servlets that are required can be developed for free and run on many free Java-enabled web servers
34
Servlets Example import javax.servlet.*; import javax.servlet.http.*;
public class HelloWorld extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<html>"); out.println("<body>"); out.println("<head>"); out.println("<title>Hello World!</title>"); out.println("</head>"); out.println("<h1>Hello World!</h1>"); out.println("</body>"); out.println("</html>"); }
35
Server Pages Microsoft IIS + ASP (Active Server Pages)
Sun followed suit + JSP (JavaServer Pages)
36
Java Server Pages Related to Java servlets
An extension of the Java servlet API Can be used alone or in conjunction with servlets Another method for developing server side applications We will look at these in more detail in next lecture
37
References Check out Fast CGI Mod Perl Active Server Pages (ASP)
Mod Perl Active Server Pages (ASP) Cold Fusion PHP Servlet and Java Server Page (JSP)
38
Summary We have looked at:
Client-side scripting v Server-side scripting Factors in selecting a technology Older and New technologies CGI, Fast CGI, Mod Perl, Active Server Pages (ASP), Cold Fusion Overview of Servlets Introduction to Java Server Pages (JSP)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.