Presentation is loading. Please wait.

Presentation is loading. Please wait.

-Dynamic Web Pages 데이타베이스 연구실 홍 동 숙. Product HTML is static but CGI and Web server APIs aren ’ t –Using HTML, The text and the format of its display remain.

Similar presentations


Presentation on theme: "-Dynamic Web Pages 데이타베이스 연구실 홍 동 숙. Product HTML is static but CGI and Web server APIs aren ’ t –Using HTML, The text and the format of its display remain."— Presentation transcript:

1 -Dynamic Web Pages 데이타베이스 연구실 홍 동 숙

2 Product HTML is static but CGI and Web server APIs aren ’ t –Using HTML, The text and the format of its display remain constant and cannot be changed at run time –Using CGI and major Web server APIs, you can execute a server program from an input HTML form and then generate an output HTML report based on the result of that program execution –CGI is portable but it can be slow –The Web-server unique APIs are fast but they are not portable Net.Data as a Web gateway tool –Net.Data does most of the grunt work for you and makes your job much easier when creating dynamic Web pages –Net.Data supports major Web server APIs in addition to CGI, provides access to a rich set of databases –Net.Data includes some important performance enhancement features –Net.Data serves as a good case study that illustrates many of the major issues one faces when designing and implementing a dynamic Web page generation tool

3 CGI(1) CGI allows you to invoke a program from a Web server that normally only knows how to process HTML documents –This can be done through a URL directly from a Web browser as an HTML anchor reference as an action attribute of a HTML form –http://server-name/cgi-directory-name/cgi-program When receiving such a URL –The Web server set up some environment variables and invokes the CGI program –The CGI program then reads the environment variables and starts executing –The CGI program further reads input data from the Web server through the standard input pipe, and it writes result data to the Web server through the standard output pipe –The Web server treats the results as a normal HTML document and returns it to the Web browser for display

4 CGI(2) The common architecture for Web data access using CGI involves two passes –In the first pass From a Web browser, the user downloads an HTML form using a URL The user then fills in the input data –In the second pass The user submits the HTML form whose action attribute contains a URL that specifies the name of a CGI program The Web server invokes the program that contains a SQL query on a database The CGI program collects the query results and generates a standard HTML report to be returned by the Web server for display to the user –Fg 11-1.Web Data Access Using CGI

5 CGI(3) Fg 11-2. HTTP Process Flow Calling CGI

6 CGI(4) As a developer of a CGI-based data access application –You must develop or handle the input HTML form the CGI program that accesses databases the passing of input data from the HTML form to the CGI program The generation of an HTML report based on the data access results => All these are tailored for the specific application –If another application comes along, you must repeat the whole cycle again for that application –CGI can be slow so you will have to worry about replacing CGI with Web server unique APIs and so on

7 NET.DATA(1) Net.Data is a Web gateway tool –It provides a robust and scalable framework for creating dynamic Web pages with data originating from a variety of sources Multiple platform : HP, LINUX, OS/2, SUN, WinNT … Multiple datasource ; DB2, Oracle, ODBC data sources … Multiple language environments : Java, REXX, Perl, C++ … –It is easy to use, extendable, and fast –Fg 11-3. Web Data Access Using Net.Data

8 NET.DATA(2) The development of Net.Data followed the evolution of Web data access –Net.Data was first introduced in 1995 to enable Web-based, server- side applications –It used static CGI processes and provided access to mainly DB2 databases (it was called DB2 WWW Connection) –In 1996, it added support for access to multiple data sources, Web server APIs, live connections, the use of Java applets and JavaScript on the client, and server-side JDBC processing –Major action items planned for future releases include visual programming tools, Fast CGI support, Java servlets(server-side includes), performance improvements, additional data sources, and additional platforms

9 The Net.Data Architecture(1) Net.Data applications have a 3-tier architecture –Fg 11-5. The Net.Data 3-Tier Architecture

10 The Net.Data Architecture(2) Net.Data applications have a 3-tier architecture –Net.Data itself resides on Tier 2, a Web server –Net.Data is a Web server program that can be invoked through CGI, a Web-server specific API, or as Java servlets –Net.Data applications appear in the form of macro files, which contain HTML forms, SQL queries, and optional function calls(in Java, REXX, Perl, or C) –The user of an application invokes it from the client, Tier 1, by using a URL that specifies the Net.Data executable, the name of a macro file, and the input HTML form –When the user submits the form, its action causes a certain SQL query to be executed on the database server, Tier 3 –The result of the query is used to generate an output HTML report for display to the user

11 The Net.Data Architecture(3) Net.Data consists of the major components –Fg 11-6. The Net.Data Component Architecture

12 The Net.Data Architecture(4) Net.Data consists of the major components –Macro processor It processes macro files, invokes function calls, links to language environments, and generates HTML pages –Macro files These are Net.Data applications written by users –Function library This contains Net.Data ’ s built-in functions –Language environments These are Net.Data ’ s backends or databases –Live connection It can be used to maintain and manage live connections to databases and Java virtual machines

13 Macro Processing(1) A Net.Data macro file is processed twice by the macro processor during a user session –In the first pass From a Web browser, the user invokes the macro processor using a URL that specifies the macro processor, the name of the macro file, and the name of an HTML section that defines the input HTML form The macro processor processes the macro file-specifically, the named HTML section The macro processor generates a standard HTML form to be returned by the Web server for display to the user –In the second pass The user submits the HTML form, whose action attribute contains a URL The macro processor again processes the macro file-specifically, the named HTML section-that contains a function call executing a SQL query on a database or invoking a procedure on other backends The macro processor makes the function call, collects the result, and generates a standard HTML report to be returned by the Web server for display to the users

14 Macro Processing(2) Fg 11-7. Net.Data Macro Processing : Report Generation

15 The Macro Processor(3) The macro processor can be invoked by a Web server via a URL –This can be done directly by a user, as an HTML anchor reference, or as an action attribute of an HTML form –When invoked as a CGI or ICAPI(IBM ’ s Internet Connection API) application, http://server-name/cgi-directory-name/db2www.exe/macro- filename/macro-block-name –When invoked as an NSAPI(Netscape Server API) or ISAPI(Microsoft ’ s Internet Server API) application, http://server-name/macro-filename/macro-block-name The macro processor processes macro file and performs the following tasks –Includes files, defines variable, and defines functions –Resolves variable references and invokes function calls –Loads in appropriate (language environment) libraries –Generates standard HTML pages

16 The Macro File(1) The macro file provides you with the means to add logic, variables, function calls, and reports to otherwise static HTML A macro file consists of macro statements which are denoted by a special macro symbol(% or @) The major type of macro statements : –Blocks These are used to define HTML forms and reports, variables, functions and their reports %block-type[( … )] { … %} –Function calls These are used to invoke functions @function-name( … ) –Control statements These can be used to control the flow of macro execution %if … [%elif … ] [%else … ] %endif –Comments %{ … %}

17 The Macro File(2) Three major type of macro blocks : –Define This can be used to define variables –HTML This is used to define input HTML forms and output HTML reports –Function This can be used to define language-environment specific functions Function block may include a Report block and Message block Report block –This is used to define the report to be generated Message block –This is used to define the message to be displayed in case an error occurs The macro file provides three major expressive capabilities –Variable definition and passing –Function definition and invocation –Report definition

18 The Macro File(3) Net.Data variables –can be used to pass values within a macro file or between a macro file and a language environment –All variables are character strings (they have no data types) –The major kinds of variables : Implicit –These contain data returned from SQL queries and from function calls Report –These can be used to customize report format SQL –These can be used to tailor access to databases User-defined –These are user-defined variables –User-defined variables can be defined in the Define block, defined in an HTML form ’ s INPUT or SELECT statement, or passed in as URL data –Once defined, user-defined variables can be referenced as $(variable- name) anywhere in the macro file

19 The Macro File(4) Net.Data variables –Implicit variables include : $(Nn),$(N_columnName),$(NLIST) contain column names $(Vn),$(V_columnName),$(VLIST) contain column values in the current row $(ROW_NUM) contains the row number of the current row $(NUMBER_COLUMN) contains the number of columns in the result table $(TOTAL_ROWS) contains the number of rows in the result table $(RETURN_CODE) contains the return code for use in the Message block –SQL variables include : DATABASE specifies the database to connect to LOGIN specifies the user id PASSWORD specifies the password to be used with the user id TRANSACTION_SCOPE specifies the transaction scope for SQL statements

20 The Macro File(5) Net.Data functions –can be used to add logic, access databases, or interact with external programs during macro execution –The major types of functions : Math, String manipulation, Table, User-defined –User-defined function contains the following information : Language environments, Name (Required) IN, OUT, and INOUT parameters (Optional) Return variable, Executable statements (Optional) Report block, Message block (Optional) Net.Data reports –Within a Function block you can use the Report block and Message block to define the report and message to be generated –The report block consists of the following : Header, ROW block, Footer –The Row block displays HTML formatted data once for each row of data returned from the function call –The Message block allows you to associate a message with each return code value generated by the function call and to specify the action for Net.Data

21 Language Environments(1) Net.data provides a rich set of language environments –SQL/DB2, Oracle, and Sybase with native access –ODBC –Java Applet and Java Application –REXX and Perl –System (C) Users can also build and plug in their own language environment You simply specify the SQL statement to be executed within a function body and then call the function If you want to have more control over data access, you can use the Java Applet (from the client side) or the Java Application (from the server side) language environment The Java Applet language environment can dynamically generate the following parameter specifications for an applet –NUMBER_OF_TABLES, TABLE_ _NAME, NUMBER_OF_COLUMNS, NUMBER_OF_ROWS, COLMUMN_NAME_, _VALUE_ Net.Data Java Applet Interfaces : –getNumberOfTables(), getTableNames(), getNumberOfColumns(String tableName), getNumberOfRows(String tableName), getColumnNames(String tableName), getTable(String tableName)

22 Language Environments(2) Fg 11-9. Client-Side Application with Java Applet

23 Language Environments(3) Fg 11-10. Server-Side Application with Java Application

24 Live Connection Only one database connection per macro execution –Net.Data establishes a connection to a database at the beginning of macro execution –Net.Data closes the connection at the end of macro execution Live connection allows you to create and maintain persistent connections –Live connection consists of a connection manager and cliettes –The connection manager is a separate executable from Net.Data –Cliettes are single-threaded processes that the connection manager starts, and they run continuously to service requests –Cliettes are made to handle specific language environments pre-started at Web server initialization configurable with a minimum and maximum number of processes pre-connected to specified databases or backends reusable for the same type of connection Live connection provides two major advantages –Improved performance –Multiple database access

25 Conclusion Net.Data takes the grunt work out of CGI programming and makes life much easier for you in generating dynamic Web pages based on live data Reference sites –http://www-4.ibm.com/software/data/net.data/ –http://www-4.ibm.com/software/data/net.data/docs/index.html 참고 –DB2 Universal DB V7 Packages which include Net.Data –DB2 Universal Developer's Edition –DB2 Universal Database Workgroup Edition –DB2 Universal Database Enterprise Edition (EE) –DB2 Universal Database Enterprise-Extended Edition (EEE) –DB2 Connect Enterprise Edition Fee download package (you can get it from IBM Web site) –DB2 Personal Developer's Edition –DB2 Universal DB V5 (you can get it from CD) DB2 Universal Database Workgroup Edition DB2 Universal Database Enterprise Edition


Download ppt "-Dynamic Web Pages 데이타베이스 연구실 홍 동 숙. Product HTML is static but CGI and Web server APIs aren ’ t –Using HTML, The text and the format of its display remain."

Similar presentations


Ads by Google