The Request & Response object

Slides:



Advertisements
Similar presentations
E-Commerce CMM503 – Lecture 8 Stuart Watt Room C2.
Advertisements

Cookies, Sessions. Server Side Includes You can insert the content of one file into another file before the server executes it, with the require() function.
Lecture 6/2/12. Forms and PHP The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input When dealing with HTML forms.
TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 22 World Wide Web and HTTP.
1 Active Server Pages Active Server Pages (ASPs) are Web pages ASP = server-side scripts + HTML The appearance of an Active Server Page depends on who.
Introduction to Active Server Pages
Basic Scripting in VBScript  VBScript must enclosed by  No HTML code is allowed inside a VBScript code block  Nested scripting block is not allowed.
Mark Dixon, SoCCE SOFT 131Page 1 19 – Web applications: Server-side code (ASP)
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Beginning Active Server Pages Barry Sosinsky Valda Hilley Programming.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Cookies & Sessions.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
 2004 Tau Yenny, SI - Binus M0194 Web-based Programming Lanjut Session 1.
Elements of ASP Documents Adapted from MCDN Web Workshop ( and Webmonkey’s Introduction to Active.
Python CGI programming
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
USING PERL FOR CGI PROGRAMMING
Website Development with PHP and MySQL Saving Data.
Chapter 6 Server-side Programming: Java Servlets
INT213 Week 1.  A Named storage area (in RAM) that can hold a value (like a mailbox holding a letter)  Contents of a variable can be assigned, changed.
HTML FORMS GET/POST METHODS. HTML FORMS HTML Forms HTML forms are used to pass data to a server. A form can contain input elements like text fields, checkboxes,
ASP.NET Dynamic Styles Response and Request Objects.
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
Operating Systems Lesson 12. HTTP vs HTML HTML: hypertext markup language ◦ Definitions of tags that are added to Web documents to control their appearance.
ASP Objects Active Server Pages (cont..) 1. 2 ASP : Objects ASP provides built-in objects for performing useful tasks that simplify web development.
Web Design and Development. World Wide Web  World Wide Web (WWW or W3), collection of globally distributed text and multimedia documents and files 
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Internet Applications (Cont’d) Basic Internet Applications – World Wide Web (WWW) Browser Architecture Static Documents Dynamic Documents Active Documents.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
ASP.NET P AGE O BJECTS.  Each ASP.NET page inherits the PAGE object  The PAGE supplies 3 built in objects:  REQUEST: All information passed to the.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
Raina NEC Application Object Describes the methods, properties, and collections of the object that stores information related to the entire Web.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
1 Chapter 22 World Wide Web (HTTP) Chapter 22 World Wide Web (HTTP) Mi-Jung Choi Dept. of Computer Science and Engineering
TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 22 World Wide Web and HTTP.
National College of Science & Information Technology.
Lecture 6 Sara Almudauh ASP.NET Part 1 Development of Internet Application 1501CT - Sara Almudauh.
2440: 141 Web Site Administration Web Forms Instructor: Joseph Nattey.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
4.01 How Web Pages Work.
Tonga Institute of Higher Education IT 141: Information Systems
Section 6.3 Server-side Scripting
WWW and HTTP King Fahd University of Petroleum & Minerals
Web Development Web Servers.
ASP Explained By: Sarbjit Kaur.
21 – Web applications: Server-side code (ASP)
19.10 Using Cookies A cookie is a piece of information that’s stored by a server in a text file on a client’s computer to maintain information about.
Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 19 PHP Part III Credits: Parts of the slides are based on slides created by textbook authors, P.J. Deitel and H. M. Deitel by Prentice Hall ©
PHP / MySQL Introduction
IS333D: MULTI-TIER APPLICATION DEVELOPMENT
ASP.
Client side & Server side scripting
Chapter 27 WWW and HTTP.
Browser and Server Models
Tonga Institute of Higher Education IT 141: Information Systems
Chapter 2 Interacting with the Customer
Tonga Institute of Higher Education IT 141: Information Systems
Building ASP.NET Applications
EE 122: HyperText Transfer Protocol (HTTP)
Kevin Harville Source: Webmaster in a Nutshell, O'Rielly Books
Introduction to HTML: Forms
4.01 How Web Pages Work.
Cookies A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer.
Presentation transcript:

The Request & Response object Request Object When a browser asks for a page from a server, it is called a request. The ASP Request object is used to get information from the user. Its collections, properties, and methods are described below: Collections CollectionDescription ClientCertificate Contains all the field values stored in the client certificate Cookies Contains all the cookie values sent in a HTTP request Form Contains all the form (input) values from a form that uses the post method QueryString Contains all the variable values in a HTTP query string ServerVariables Contains all the server variable values

Response Object Response Object The ASP Response object is used to send output to the user from the server. Its collections, properties, and methods are described below: Method Description AddHeader Adds a new HTTP header and a value to the HTTP response AppendToLog Adds a string to the end of the server log entry BinaryWrite Writes data directly to the output without any character conversion Clear Clears any buffered HTML output End Stops processing a script, and returns the current result Flush Sends buffered HTML output immediately Redirect Redirects the user to a different URL Write Writes a specified string to the output

Sending Info to the server The Request object retrieves the values that the client browser passed to the server during an HTTP request. It is used to send information to server. Using this object, you can dynamically create web pages and perform various server-side actions based on input from the user. Example

Sending info back to client The Response object is used to send output to the client from the web server. The Response.write() <html> <body> <% response.write("Hello World!") %> </body> </html> Formatted Ex

Clear Method Response.clear() <% Response.Buffer=true %> <html> <body> <p>This is some text I want to send to the user.</p> <p>No, I changed my mind. I want to clear the text.</p> <% Response.Clear %> </body> </html>

Flush Method <% Response.Buffer=true %> <html> <body> <p> This text will be sent to your browser when my response buffer is flushed. </p> <% Response.Flush %> </body> </html>

End Method <%@ language=VBScript %> <% Option Explicit %> <% Response.Buffer=true %> <HTML> <BODY> <% Response.Write(“Before End & Flush”) Response.Flush Response.Write(“After Flush, before End <BR>”) Response.End Response.Write(“After End”) %> </body> </html>

Redirect Method <%@ language=VBScript %> <% Option Explicit %> <% Response.Buffer=True %> <HTML> <BODY> <% Dim apass, bpass, cpass bpass="bill" cpass="bill" apass=(bpass=cpass) if apass then Response.redirect "members.html" else Response.write "Invalid Password" end if %> </body> </html>

Server Variables This example demonstrates how to find out the visitors (yours) browser type, IP address, and more with the ServerVariables collection. Server variables can browse browser info, IP add, DNS, Method, server name, server port, server software etc. Example

Controlling Information In addition to sending HTML code back to the client, the Response object can be used to control some of the things that the browser itself does. If you want the browser to cache the page that you are creating until a certain date, or for a certain length of time, you can use the Response object to pass the browser this information. If the browser requested a certain page, but you really think that it should be displaying another page, you can use the Response object to tell the browser to go get another page. This could be used if you have moved a page in your site, but still want people with links to the original page to be able to get to the information. This technique is now becoming outdated with the introduction of the Transfer and Execute methods for the Server object in ASP 3.0.

Content Expiration The Expires property specifies the length of time (in minutes) before a page cached on a browser expires. If the user returns to the same page before it expires (and the page is allowed to be cached), the cached version is displayed. Example: <% Response.Expires = 15 %> This will result in the page expiring after 15 minutes. If you set the Expires property more then once on a single page, the server will use the shortest time period.

Server.Execute The Server.Execute method is a new ASP method, introduced with IIS 5.0 for a first time. You can execute a child ASP page with the Server.Execute and treat the child ASP page as part of the main page. What are the advantages of using Server.Execute, why did Microsoft introduce a new method? The main advantage of using Server.Execute is that you can do a dynamic conditional execution of an ASP pages. For example with the SSI includes you include file like this: <-- #include File = "c:\Inetpub\wwwroot\Your_App\include1.asp" --> <-- #include Virtual = " /Your_App/include1.asp" --> One problem with the #include command that it is processed before the page is executed, while the Server.Execute method can be used after the ASP page processing has started. The developers can conditionally execute ASP pages depending the main page business logic or on the user input with Server.Execute method. Page1 Page2 Page3a Page3b

Transferring Control to another Page Server.Transfer is used to transfer control to another ASP page. When it is called, all the data related to the calling page is transferred to the new page. This means that if variables of session or application scope has been given values, those values are kept in the new page. State information and values for the built-in objects are transferred, too. Also the contents of the request collections are kept and are available to the new page. You can even perform a server.Transfer between two pages in separate applications. In this case, the value of the application variables and objects will be the same as if the second page were in the same application as the first. That is, the values of application scope variables and objects are kept after the transfer.

Demonstrates How to Use Server.Execute <%@ LANGUAGE=VBSCRIPT %> <% Option Explicit %> <HTML> <BODY> <% Response.Write( “I am in page 1 <BR>”) Server.Transfer(“page2.asp”) Response.Write(“Back in page 1”) %> < / BODY> </HTML> This page is almost identical to page1.asp. the only difference is that line 7 uses a server. Transfer in place of the server.Execute. You can see the result of this listing. Notice that in this version, the third line is not printed. That is because you never return to the calling page when you do a server.Transfer. In this regard, server.Transfer may be used a bit like the Response. Redirect. Example