1 / 65

Lecture 3 Web Technologies Part 2

Lecture 3 Web Technologies Part 2. Web Technologies. HTML XHTML CSS XML JavaScript VBSCRIPT DOM DHTML AJAX E4X WMLScript SQL. ASP ADO PHP CGI PERL .NET SMIL SVG FLASH Java applets Java servlets Java Server page. What is SQL?.

keaton-ross
Download Presentation

Lecture 3 Web Technologies Part 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 3Web TechnologiesPart 2

  2. Web Technologies • HTML • XHTML • CSS • XML • JavaScript • VBSCRIPT DOM • DHTML • AJAX • E4X • WMLScript • SQL • ASP • ADO • PHP • CGI • PERL • .NET • SMIL • SVG • FLASH • Java applets • Java servlets • Java Server page

  3. What is SQL? • SQL stands for Structured Query Language • SQL allows you to access a database • SQL can execute queries against a database • SQL can retrieve data from a database • SQL can insert new records in a database • SQL can delete records from a database • SQL can update records in a database • SQL is easy to learn

  4. SQL Data Manipulation Language (DML) • SQL (Structured Query Language) is a syntax for executing queries. But the SQL language also includes a syntax to update, insert, and delete records. • These query and update commands together form the Data Manipulation Language (DML) part of SQL: • SELECT - extracts data from a database table • UPDATE - updates data in a database table • DELETE - deletes data from a database table • INSERT INTO - inserts new data into a database table

  5. SQL Data Definition Language (DDL) • The Data Definition Language (DDL) part of SQL permits database tables to be created or deleted. We can also define indexes (keys), specify links between tables, and impose constraints between database tables. • The most important DDL statements in SQL are:  • CREATE TABLE - creates a new database table • ALTER TABLE - alters (changes) a database table • DROP TABLE - deletes a database table • CREATE INDEX - creates an index (search key) • DROP INDEX - deletes an index

  6. SQL on the WEB • Many web applications require database at the back side. • We can use SQL for database activities. • We use SQL together with other technologies.

  7. SQL Example with ASP <html> <head> <title>My First ASP Page</title> </head> <body bgcolor="white" text="black"> <% Dim adoCon Dim rsGuestbook Dim strSQL 'Create an ADO connection object Set adoCon = Server.CreateObject("ADODB.Connection") 'Set an active connection to the Connection object using a DSN-less connection adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("mydb.mdb") 'Create an ADO recordset object Set rsGuestbook = Server.CreateObject("ADODB.Recordset") 'Initialise the strSQL variable with an SQL statement to query the database strSQL = "SELECT Friends.Name, Friends.link FROM Friends;" 'Open the recordset with the SQL query rsGuestbook.Open strSQL, adoCon

  8. SQL Example with ASP 'Loop through the recordset Do While not rsGuestbook.EOF 'Write the HTML to display the current record in the recordset Response.Write ("<br>") Response.Write (rsGuestbook("Name")) Response.Write ("<br>") Response.Write (rsGuestbook("link")) Response.Write ("<br>") Response.Write("Murat Koyuncu") 'Move to the next record in the recordset rsGuestbook.MoveNext Loop 'Reset server objects rsGuestbook.Close Set rsGuestbook = Nothing Set adoCon = Nothing %> </body> </html>

  9. What is ASP? • ASP stands for Active Server Pages. • ASP is a program that runs inside IIS. • IIS stands for Internet Information Services. • IIS comes as a free component with Windows Servers. • PWS is a smaller - but fully functional - version of IIS (for Windows 95/98).

  10. ASP Compatibility • ASP is a Microsoft Technology. • To run IIS you must have Windows NT 4.0 or later. • To run PWS you must have Windows 95 or later.

  11. What is an ASP File? • An ASP file is just the same as an HTML file. • An ASP file can contain text, HTML, XML, and scripts. • Scripts in an ASP file are executed on the server. • An ASP file has the file extension ".asp“.

  12. How Does ASP Differ from HTML? • When a browser requests an HTML file, the server returns the file. • When a browser requests an ASP file, IIS passes the request to the ASP engine. • The ASP engine reads the ASP file, line by line, and executes the scripts in the file. • Finally, the ASP file is returned to the browser as plain HTML.

  13. What can ASP do for you? • Dynamically edit, change or add any content of a Web page. • Respond to user queries or data submitted from HTML forms. • Access any data or databases and return the results to a browser. • Customize a Web page to make it more useful for individual users. • The advantages of using ASP instead of CGI and Perl, are those of simplicity and speed. • Provide security since your ASP code can not be viewed from the browser. • Clever ASP programming can minimize the network traffic. Important: Because the scripts are executed on the server, the browser that displays the ASP file does not need to support scripting at all!

  14. ASP Example <html> <body><%response.write("Hello World!")%> </body> </html>

  15. ASP Example-Code <html> <body><%response.write(FormatDateTime(date(),vbgeneraldate))response.write("<br />")response.write(FormatDateTime(date(),vblongdate))response.write("<br />")response.write(FormatDateTime(date(),vbshortdate))response.write("<br />")response.write(FormatDateTime(now(),vblongtime))response.write("<br />")response.write(FormatDateTime(now(),vbshorttime))%><p>Syntax for FormatDateTime:FormatDateTime(date,namedformat).</p></body></html>

  16. ASP Example-Output 12/10/2007 Monday, December 10, 2007 12/10/2007 9:16:58 AM 09:16 Syntax for FormatDateTime: FormatDateTime(date,namedformat).

  17. What is ADO? • ADO is a Microsoft technology. • ADO stands for ActiveX Data Objects. • ADO is a Microsoft Active-X component. • ADO is automatically installed with Microsoft IIS. • ADO is a programming interface to access data in a database.

  18. Accessing a Database from an ASP Page The common way to access a database from inside an ASP page is to: • Create an ADO connection to a database. • Open the database connection. • Create an ADO recordset. • Open the recordset. • Extract the data you need from the recordset. • Close the recordset. • Close the connection.

  19. Create a Database Connection <% setconn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open "c:/webdata/northwind.mdb" %>

  20. An ODBC Connection to an MS Access Database Here is how to create a connection to a MS Access Database:  • Open the ODBC icon in your Control Panel. • Choose the System DSN tab. • Click on Add in the System DSN tab. • Select the Microsoft Access Driver. Click Finish. • In the next screen, click Select to locate the database. • Give the database a Data Source Name (DSN). • Click OK.

  21. An ODBC Connection to an MS Access Database <% set conn=Server.CreateObject ("ADODB.Connection") conn.Open "northwind" %> Name defined in ODBC

  22. Create an ADO Table Recordset <% Setconn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open "c:/webdata/northwind.mdb“ Setrs=Server.CreateObject("ADODB.recordset") rs.Open "Customers", conn %>

  23. Create an ADO SQL Recordset <% Set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0“ conn.Open "c:/webdata/northwind.mdb“ set rs=Server.CreateObject("ADODB.recordset") rs.Open "Select * from Customers", conn %>

  24. Extract Data from the Recordset <% ..... for each x in rs.fields response.write(x.name) response.write(" = ") response.write(x.value) next .... %>

  25. ADO Example <html> <body> <% setconn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open "c:/webdata/northwind.mdb“ set rs = Server.CreateObject("ADODB.recordset") rs.Open "SELECT * FROM Customers", conn do until rs.EOF for each x in rs.Fields Response.Write(x.name) Response.Write(" = ") Response.Write(x.value & "<br />") next Response.Write("<br />") rs.MoveNext loop rs.close conn.close %> </body> </html>

  26. What is PHP? • PHP stands for PHP: Hypertext Preprocessor. • PHP is a server-side scripting language, like ASP. • PHP scripts are executed on the server. • PHP supports many databases (MySQL, Informix, Oracle, Sybase,Solid,PostgreSQL,Generic ODBC, etc.) • PHP is an open source software (OSS). • PHP is free to download and use.

  27. What is a PHP File? • PHP files may contain text, HTML tags and scripts. • PHP files are returned to the browser as plain HTML. • PHP files have a file extension of ".php", ".php3", or ".phtml"

  28. Why PHP? • PHP runs on different platforms (Windows, Linux, Unix, etc.). • PHP is compatible with almost all servers used today (Apache, IIS, etc.). • PHP is FREE to download from the official PHP resource: www.php.net. • PHP is easy to learn and runs efficiently on the server side.

  29. A free web server platform • Install an Apache server on a Windows or Linux machine. • Install PHP on a Windows or Linux machine. • Install MySQL on a Windows or Linux machine.

  30. What do PHP code look like? • PHP is a rather simple language. • Much of its syntax is borrowed from C except for dealing with the types of variables. • You don't need to think of the types of variables at all - you just work with their values, not their types. • And you don't have to declare variables before you use them.

  31. A simple PHP example <html> <body> <?php echo "Hello World"; ?> </body> </html>

  32. PHP Examples <html> <body> <?php $d=date("D"); if ($d=="Fri") echo "Have a nice weekend!"; else echo "Have a nice day!"; ?> </body> </html> <html> <body> <?php for ($i=1; $i<=5; $i++) { echo "Hello World!<br />"; } ?> </body> </html>

  33. PHP Database Example <?php $con = mysql_connect("localhost","peter","abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); $result = mysql_query("SELECT * FROM person"); while($row = mysql_fetch_array($result)) { echo $row['FirstName'] . " " . $row['LastName']; echo "<br />"; } mysql_close($con); ?>

  34. PHP ODBC Connection <html> <body> <?php $conn=odbc_connect('northwind','',''); if (!$conn) {exit("Connection Failed: " . $conn);} $sql="SELECT * FROM customers"; $rs=odbc_exec($conn,$sql); if (!$rs) {exit("Error in SQL");} echo "<table><tr>"; echo "<th>Companyname</th>"; echo "<th>Contactname</th></tr>"; while (odbc_fetch_row($rs)) { $compname=odbc_result($rs,"CompanyName"); $conname=odbc_result($rs,"ContactName"); echo "<tr><td>$compname</td>"; echo "<td>$conname</td></tr>"; } odbc_close($conn); echo "</table>"; ?> </body> </html>

  35. What is CGI? • The Common Gateway Interface (CGI) is a standard for interfacing external applications with information servers, such as HTTP or Web servers. • A plain HTML document that the Web daemon retrieves is static, which means it exists in a constant state: a text file that doesn't change. • A CGI program, on the other hand, is executed in real-time, so that it can output dynamic information.

  36. What is CGI? • For example, let's say that you wanted to "hook up" your Unix database to the World Wide Web, to allow people from all over the world to query it. • Basically, you need to create a CGI program that the Web daemon will execute to transmit information to the database engine, and receive the results back again and display them to the client. • This is an example of a gateway, and this is where CGI, currently version 1.1, got its origins.

  37. What is CGI? • A CGI program can be written in any language that allows it to be executed on the system, such as: • C/C++ • Fortran • PERL • TCL • Any Unix shell • Visual Basic • AppleScript

  38. What is MS .NET • .NET is Microsoft's new Internet and Web strategy. • .NET is NOT a new operating system. • .NET is a new Internet and Web based infrastructure. • .NET delivers software as Web Services. • .NET is a framework for universal services. • .NET is a server centric computing model. • .NET will run in any browser on any platform. • .NET is based on the newest Web standards.

  39. .NET Internet Standards • HTTP, the communication protocol between Internet Applications. • XML, the format for exchanging data between Internet Applications. • SOAP, the standard format for requesting Web Services. • UDDI, the standard to search and discover Web Services.

  40. .NET Framework • The .NET Framework is the infrastructure for the new Microsoft .NET Platform.  • The .NET Framework contains common class libraries - like ADO.NET, ASP.NET and Windows Forms. • The .NET Framework is language neutral. Currently it supports C++, C#, Visual Basic, JScript (The Microsoft version of JavaScript) and COBOL. • The new Visual Studio.NET is a common development environment for the new .NET Framework.

  41. .NET Framework

  42. .NET Building Blocks • Web Services: Web Services provide data and services to other applications (HTTP, HTML, XML, and SOAP). • Internet Directory Services: .NET supports a new kind of directory services that can answer XML based questions about Internet Services, far more exactly than search engines and yellow pages. These services are built on the UDDI standard. • There are also some others…

  43. .NET Software • Windows.NET: Windows 2000 and Windows XP • ASP.NET • Visual Studio.NET • Visual Basic.NET • SQL Server 2000 • Internet Information Services 6.0

  44. XML Based Web Protocols • SOAP: SOAP (Simple Object Access Protocol) is a lightweight platform and language neutral communication protocol that allows programs to communicate via standard Internet HTTP. SOAP is standardized by the W3C. • WSDL: WSDL (Web Services Description Language) is an XML-based language used to define web services and to describe how to access them. WSDL is a suggestion by Ariba, IBM and Microsoft for describing services for the W3C XML Activity on XML Protocols. • UDDI: UDDI (Universal Description, Discovery and Integration) is a directory service where businesses can register and search for web services.UDDI is a public registry, where one can publish and inquire about web services.

  45. Web service

  46. Java Applet? • What is Java applet? • What is Java servlet? • What is JavaServer Pages? • What is Java Web Start?

  47. Java Applet • An applet is a software component that runs in the context of another program, for example a web browser. • A Java applet is an applet delivered in the form of Java bytecode. Java applets can run in a Web browser using a Java Virtual Machine (JVM), or in Sun's AppletViewer, a stand-alone tool for testing applets.

  48. Java Applet • Java applets are usually written in the Java programming language but they can also be written in other languages that compile to Java bytecode. • Applets are used to provide interactive features to web applications that cannot be provided by HTML. • Since Java's bytecode is platformindependent, Java applets can be executed by browsers for many platforms, including Windows, Unix, Mac OS and Linux.

  49. Java bytecode • Java bytecode is the form of instructions that the Java virtual machine executes. • Each bytecode instruction is one byte in length. • Code: • 0: iconst_2 • 1: istore_1 • 2: iload_1 • 3: sipush 1000 • 6: if_icmpge 44 • 9: iconst_2 • 10: istore_2 • 11: iload_2 • 12: iload_1 • 41: goto 2 • 44: return

  50. What Is a Servlet? • Web server response can be static or dynamic • Static: HTML document is retrieved from the file system and returned to the client • Dynamic: HTML document is generated by a program in response to an HTTP request • Java servlets are one technology for producing dynamic server responses • Servlet is a class instantiated by the server to produce a dynamic response

More Related