When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles [1.x] [2.0]
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips
Search

Sections:
Book Reviews
Sample Chapters
Commonly Asked Message Board Questions
Headlines from ASPWire.com
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
Web Hosts
XML Info
Information:
Advertise
Feedback
Author an Article
Technology Jobs

















internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers
ASP ASP.NET ASP FAQs Message Board Feedback ASP Jobs
Print this page.

Windows Systems Administrator
Jupitermedia
US-CT-Darien

Justtechjobs.com Post A Job | Post A Resume

The Response Object


One of the most important objects in ASP is the Response object. It is the object which communicates between the server and the output which is sent to the client. To write an ASP page, all you need to do is write a standard HTML page, putting in the Active Server Pages script where needed. Active Server Pages script is denoted by the text between <%'s and %>'s.

To send ASP to the client, you need to use the Response object. The method of the Response object which sends data to the client is the Write method. For example, if you write an HTML page which looks like:

<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<BODY>
   <% Response.Write("Hello, World!") %>
</BODY>
</HTML>

if a user views the page with a standard browser, they will see the text, "Hello, World!" on the screen. It's as if you had just written an HTML page with the words "Hello, World!" where the <%'s the text between and the %>'s were. Of course, unlike an HTML page which is sent directly to the client, this page has passed through the server's ASP.DLL, parsing it so that instead of the client seeing <% Response.Write("Hello, World!") %>, the client merely sees "Hello, World!" Even if the user goes to View Source in their browser, they will only see the "Hello, World!" This is because the client is never sent the preprocessed ASP script.

You can inherently invoke the Response.Write method by using the equals (=) sign. Here is an example, which happens to produce the exact same output as above:

<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<BODY>
   <%="Hello, World!" %>
</BODY>
</HTML>

As you notice, we just got rid of the Response.Write( ... ), but left the stuff in between. The = simulates Response.Write.

There are also a few other neat properties in the Response object. One is Expires, which sets how soon your page expires. Many modern browsers cache pages for quicker downloading times. You can use ASP to set how often the browser checks to see if it needs to redownload the page. You set it in terms on minutes. If you want to browser not to cache the page, you can set Response.Expires = 0. Let's look at an example where we set the page to expire in 10 minutes.

<%@ LANGUAGE="VBSCRIPT" %>
<%
   Response.Expires = 10
%>

<HTML>
<BODY>
   This page will expire in 10 minutes
</BODY>
</HTML>

Pretty neat, eh? Another neat property of the Response object is the Buffer property, which takes either a true or false value. If buffer is set to true, the server processes the entire ASP script before sending any of the file to the client. If buffering is set to false (which it is by default), the server will send data to the client as it processes it. Below is an example of setting buffering to true:

<%@ LANGUAGE="VBSCRIPT" %>
<%
   Response.Buffer = true
%>

<HTML>
<BODY>
   This page's output to the client was buffered
</BODY>
</HTML>

FAQ Table of Contents   ASP's Server Side Languages Variables in ASP 


Windows Internet Technology | ASP.NET [1.x] [2.0] | ASPMessageboard.com | ASPFAQs.com | Advertise | Feedback | Author an Article



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Win Server ‘08
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES