Active Server Pages Architecture
Total Page:16
File Type:pdf, Size:1020Kb
Active Server Pages Architecture Li Yi South Bank University Contents 1. Introduction ...................................................................................................................................... 2 1.1 Host-based databases ............................................................................................................... 2 1.2 Client/server databases ............................................................................................................ 2 1.3 Web databases........................................................................................................................... 3 2. Active Server Pages ........................................................................................................................ 5 2.1 ASP Components ...................................................................................................................... 6 2.2 ADO and Database................................................................................................................... 7 2.3 The steps of executing a query ............................................................................................. 11 3 ASP Attributes ................................................................................................................................ 12 References:.......................................................................................................................................... 13 1 1. Introduction The development of databases always comes with the newer and better hardware and the demand for applications that match the new hardware. In the past 20 years, we have seen the development of databases not only in DBMS, but also in the evolution of database connectivity, which is from centralised computing to Client/Server computing. These client/server structure databases have a great impact to the use of databases. 1.1 Host-based databases The host-based databases are performed on one computer system with attached unintelligent, "dumb," terminals. A limited number of users can only connect to the databases running on the monolithic mainframe through the dumb monitors. There is no friendly interface at all for the users. When the users want to do queries, they must know schema of the databases clearly. What they have typed in will send to the mainframe without any processing. The application of databases will do everything. As a result, the users of the databases will be limited because each user occupies resource of the mainframe independently, even worse the mainframe will be easily overloaded because it will do everything from any trivial things to complicated businesses queries. The performance of the databases will be very poor when the users climbs up to a certain number. 1.2 Client/server databases When the number of users accessing a database grows too high or when too many features are integrated into the database, it is increasingly possible that the centralising database model fails. And with the proliferation of low-cost hardware, especially the advent of cheap PCs, client/server databases have gained popularity in the recent years. 2 Client/server has revolutionised the way of designing and building databases applications. It splits the processing load between clients and servers to get the best of both worlds. A database application is two-tier or three-tier based on the separation of the application logic from the Graphic User Interface (GUI) and the database. In a two-tier client/server database, the application logic is buried either inside GUI on the client (fat client) or within the database on the server (fat server) or both. A user runs a GUI on the client, and then sends queries over a network to a database server. The database server processes the request and returns a result. Simplicity is a good feature of two-tier databases, the two-tier databases are easier to develop than the three-tier or N-tier for small databases. But the databases do not scale well. Many SQL statements are sent over the network and selected data must be downloaded for analysis on the client. When new and more stringent requirements must be introduced into databases, two-tier databases become exponentially harder to develop and normally failed. Three-tier was designed to meet this new challenge. In a three-tier or N-tier (more than three tiers) client/server database, the application logic (or process) lives in the middle-tier. Instead of interacting with the database server directly, the client calls business logic on the server. The business logic then accesses the database on the client's behalf. Only service requests and responses are sent between the client and server, so it performs much well than two-tier. It also provides better security by not exposing the database schema to the client and by enabling more fine-grained authorisation on the server. 1.3 Web databases Web technology is a very special case in client/server computing world. Almost every database vendor is rushing to support this technology at the moment. There are two reasons to explain this, one is that enterprise web servers need powerful databases to support, and the other reason is that 3 databases need to be extended their services to the biggest wide range group, web group. The typical web databases are three-tier or N-tier. The users run standard browsers on the client side and the requests are transferred over the Internet to HTTP servers. The HTTP servers then interact with database servers and change the result into HTML files to send back to the browsers. Because HTTP is a stateless connection protocol, web databases need find a way to "remember" each user's operations. They also should have capability of handling with enormous users concurrently. If the web databases support Java, or ODBC/JDBC, they are platform independent because they can connect with different web servers or the Internet directly. It does not need to care about server platform, client platform and network protocol. Performance is a big problem of web databases. Users concern the response time of the databases and the web masters concern the throughput. Optimisation is always used at web server. When a web server receives a service request from a client, it first looks up a result in its cache to see if it is there already. If it does, the result will send back to the client directly without connecting to a database server. If it can not find the result in the cache, it will connect to the database server and fetch the result. The result will normally stored in the server cache and send back to the client. When there are more than one user's request coming into the web server, a queue will be built on web server and optimisation will make them use the server resource reasonably. Web databases can be two-tie, three-tie or N-tie. The two-tie web databases are the simplest to develop and may gain some good performance from this simple structure. However, they are lack of flexibility to deal with other web things and normally they are vendor dependence. The three-tie or N-tie web databases are powerful and flexible. But the middle tie may add the overhead because the databases are not connected with the Internet directly. 4 2. Active Server Pages Active Server Pages (ASP) is an Internet Server Application Programming Interface (ISAPI) extension which builds on top of the ISAPI infrastructure to provide a server-side application framework, making it even easier to build dynamic Web applications. ISAPI is an alternative approach to Common Gateway Interface (CGI) and is adopted by Internet Information Server (IIS) because each CGI invocation of process is very resource intensive and a busy Web server could have severe performance problems. If web technologies are used to deal with database via HTTP, then the data and its state need to be kept track of, as it flies around the world. ASP is an excellent tool to help developers do that on the Windows NT world. ASP is supplied with ActiveX Data Objects (ADO) that provides a high performance interface to databases that are Open Database Connectivity (ODBC) or OLE DB compliant. Fig. 1 shows the general structure of how ASP to connect the databases. Server: Windows NT Internet Information Server CGI Client Scripts Browser Internet ASP WWW SQL ADO Server ODBC Or Oracle ActiveX HTML MTS files Fig. 1 The connectivity of ASP with the database on the web 5 *ADO is a high-level interface, which is a wrapper around OLE DB. OLE DB is a COM- based, low-level programming interface that provides access to data from all parts of an organisation (relational, access, file). * If there is a native OLE DB provider for the database, it does not have to go through ODBC - the extra layer of processing. 2.1 ASP Components Active Server Pages allows the developer to include VBScript or JScript code in the HTML pages, which is executed on the server. ASP has its own object model, which is exposed for the above scripting languages. Its built-in objects give the way to integrate code with the requests sent from the browser, and the web pages, or responses, sent back from the server. There are six built-in objects provided by the Active Server Pages core engine. These objects are Application, Session, Response, Request and ObjectContext. They only relate to each other logically, not in a hierarchy object models. The diagram below shows how these objects fit together. Server Request Object Server Client Response Application ObjectContext Session Fig. 2 The built-in objects