IBM Computer, Laptops and Servers

Back Homepage Content Directory Resource Guide Blog

Sending Content to the Browser

Laptop Battery

A cookie is a small piece of data that is sent to your Internet browser from a Web server and stored on your computer's hard drive.

Thinkpad As a script in an ASP page is processed, any text or graphics not enclosed

A cookie is a small piece of data that is sent to your Internet browser from a Web server and stored on your computer's hard drive.

Microsoft within ASP delimiters or <SCRIPT> tags is simply returned to the browser.

This numerical data is sent to the user's browser from a Web server and then stored onto the user's computer hard drive.

Laptop Computers You can also explicitly send content to the browser by using the

A cookie is a small piece of data that is sent to your Internet browser from a Web server and stored on your computer's hard drive.

Laptop Computer Response object.

A cookie is a small piece of data that is sent to your Internet browser from a Web server and stored on your computer's hard drive.

Desktop Computer To send content to the browser from within ASP delimiters or from a

Notebooks procedure, use the Write method of the

Lenovo Response object. For example, the following statement sends a

Hard Drive different greeting to the user depending on whether the user has visited the

Travelstar page before:<%

Gateway If blnFirstTime Then

Laptop Parts Response.Write "<H3 ALIGN=CENTER>Welcome to the Overview Page.</H3>"

Software Else

Hard Drives Response.Write "<H3 ALIGN=CENTER>Welcome Back to the Overview Page.</H3>"

Electronics End If

Canon %>

Desktop Pc Outside of a procedure, you do not have to use

Desktop Computers Response.Write to send content back to the user. Content that

Think Pad is not within scripting delimiters is sent directly to the browser, which

Repair formats and displays this content accordingly. For example, the following script

Data Recovery produces the same output as the previous script:<H3 ALIGN=CENTER>

Cisco <% If blnFirstTime Then %>

Keyboard Welcome to the Overview Page.

Monitor <% Else %>

Desktop Welcome Back to the Overview Page.

Infosys <% End If %>

Refurbished Laptops </H3>

Wipro Intersperse script commands and HTML when you just need to return output once

Lap Top or when it is more convenient to add statements to existing HTML text. Use

Refurbished Response.Write when you do not want to break up a statement

Memory with delimiters or when you want to build the string that is returned to the

Intel browser. For example, you could construct a string of text that builds a table

As400 row with values sent by an HTML form:Response.Write "<TR><TD>" & Request.Form("FirstName") _

Averatec & "</TD><TD>" & Request.Form("LastName") & "</TD></TR>"

Hardware Request.Form returns the values sent from an HTML form (see

Dual Xeon ).

Storage Note   The ampersand character (&) is the

Seagate string-concatenation character for VBScript. The underscore (_) is the VBScript

Computer Sales line-continuation character.

Computer Hardware When the Web server returns a file to a browser, it tells the browser what

Printers type of content is contained in the file. This enables the browser to determine

Technology whether it can display the file itself or whether it has to call another

Mainframe application. For example, if the Web server returns a Microsoft Excel worksheet,

Samsung the browser must be able to start a copy of Microsoft Excel to display the page.

Computer Repair The Web server recognizes file types by mapping the file name extension to a

Used Computers list of MIME (Multipurpose Internet Mail Extensions) types. For

Network example, to start Microsoft Excel, the browser needs to recognize the

Digital Cameras application/vnd.ms-excel MIME type.

Desktops You can use the ContentType

Cognos property of the Response object to set the HTTP content type

Hosting string for the content you send to a user. For example, the following command

Netfinity sets the content type for channel definitions:<% Response.ContentType = "application/x-cdf" %>

Internet For more information about channels, see in this topic.

Cheap Computer Other common content types are text/plain (for content returned as text

Digital Camera instead of interpreted HTML statements), image/gif (for GIF images), image/jpeg

Printer (for JPEG images), video/quicktime (for movies in the Apple QuickTime?format),

Xseries and text/xml (for XML documents). In addition, a Web server or Web browser may

Maxtor support custom MIME types. To see the content types already defined by your

Data Storage Microsoft Web server, use the

Hitachi to open the property sheets for your Web site, click the HTTP

Rational Headers tab, and then click the File Types tab. These

Websphere file types may be used as a reference when you choose to manually set the

Battery content type with ASP.

It Support Instead of sending content to a user, you can redirect the browser to another

Western Digital URL with the Redirect method. For example, if you want to make

Music sure users have entered your application from a home page so that they receive a

Networks customer ID, you can check to see if they have a customer ID; if they do not,

Toner you can redirect them to the home page.<%

Cheap Laptops If Session("CustomerID") = "" Then

Wholesale Response.Redirect "Register.asp"

Brother End If

Netvista %>

Camera server-side scripts which are processed before any content is sent to the

Networking user are said to be buffered. ASP enables you to turn buffering on or

Sharp off, and this configuration can greatly affect the behavior of the

Cheap Redirect method. Specifically, if you have buffering turned

Windows off, then you must redirect the browser before your page's HTTP headers are

Monitors returned to the browser.

Linux Place the Response.Redirect statement at the top of the

Computer Support page, before any text or <HTML> tags, to ensure that nothing has been

Used Laptops returned to the browser. If you use Response.Redirect after

Cameras content or headers have been returned to the browser, you will see an error

Scanners message. Also note that Response.Redirect does not

Panasonic need to be followed by .

Workstation If you want to use Response.Redirect from the middle of a

Iseries page, use it along with the Response.Buffer property, as

Backup explained in the section in this

Information Technology topic.

Routers Transferring Between .ASP Files

180gxp Using Response.Redirect to redirect a browser requires a

Notebook Battery round-trip, meaning that the server sends an HTTP response to the

Security browser indicating the location of the new URL. The browser automatically leaves

Lotus the server's request queue and sends a new HTTP request for this URL. The server

Virus then adds this request to the request queue along with other client's requests

Thinkpad T42 that arrived in the meantime. For a busy Web site, round-trips can waste

Thinkpad 600 bandwidth and reduce server performancespecially when the browser is

Thinkpad 600e redirected to a file located on the same sever.

Thinkpad 570 You can use the Server.Transfer method to transfer from one

Thinkpad 600x .asp file to another file located on the same server instead of the

Thinkpad 390x Response.Redirect method. With Server.Transfer

Thinkpad A31 you can directly transfer requests for .asp files without ever leaving the

Thinkpad X20 server request queue, thus eliminating costly round-trips.

Bios Update For example, the following script demonstrates how you could use

Laptops Server.Transfer to jump between the pages of an application

Toshiba depending on state information:<%

Laptop Battery If Session("blnSaleCompleted") Then

Thinkpad Server.Transfer("/Order/ThankYou.asp")

Microsoft Else

Laptop Computers Server.Transfer("/Order/MoreInfo.asp")

Laptop Computer End if

Desktop Computer %>

Notebooks

Lenovo Server.Transfer sends requests from one executing .asp file

Hard Drive to another file. During a transfer, the originally requested .asp file

Travelstar immediately terminates execution without clearing the output buffer (for more

Gateway information, see the section). Request

Laptop Parts information is then made available to the destination file when it begins

Software execution. During execution, this file has access to the same set of intrinsic

Hard Drives objects (Request, Response,

Electronics Server, Session, and

Canon Application) as the originally requested file.

Desktop Pc You can also use Server.Transfer to transfer between .asp

Desktop Computers files located in different applications. However, when you transfer to an .asp

Think Pad file located in another application, the file will behave as if it was part of

Repair the application that initiated the transfer (that is, the file has access only

Data Recovery to variables scoped for the initiating application, not for the application

Cisco where the file actually resides). For example, if you transfer from a file

Keyboard located in the Sales Application to a file located in the Personnel Application,

Monitor then the Sales Application effectively borrows this file from the Personnel

Desktop Application and runs it as if it were part of the Sales Application.

Infosys ASP also provides the Server.Execute command that you can

Refurbished Laptops use to transfer to a file, execute its content, and then return to the file that

Wipro initiated the transfer. If you are familiar with VBScript, it will help you to

Lap Top think of Server.Execute as analogous to a procedure call,

Refurbished except that instead of executing a procedure, you are executing an entire .asp

Memory file.

Intel For example, the following script demonstrates how you could use

As400 Server.Execute to do dynamic inclusion of .asp files:<%

Averatec .

Hardware .

Dual Xeon .

Storage If blnUseDHTML Then

Seagate Server.Execute("DHTML.asp")

Computer Sales Else

Computer Hardware Server.Execute("HTML.asp")

Printers End If

Technology .

Mainframe .

Samsung .

Computer Repair %>

Used Computers

Network As long as the destination file belongs to an application on the same server,

Digital Cameras the originating application will transfer to this file, execute its contents,

Desktops and then resume executing the file that initiated the transfer. Just as with

Cognos Server.Transfer, an executed .asp file behaves as if it were

Hosting part of the originating application. Server.Execute, however,

Netfinity will not work across servers. For more information, see Server.Execute.

Internet By default, the Web server processes all script commands on a page before any

Cheap Computer content is sent to the user. This process is known as buffering. You

Digital Camera can use the Buffer property of the Response

Printer object to disable buffering, so that the Web server returns HTML and the results

Xseries of scripts as it processes a page.

Maxtor The advantage of buffering your .asp files is that you can abort sending a

Data Storage Web page if, for example, the script processing does not proceed correctly or if

Hitachi a user does not have appropriate security credentials. Instead, you can transfer

Rational the user to another page using Server.Transfer, or clear the

Websphere buffer (using the the Clear method of the

Battery Response object) to send different content to the user.

It Support Depending on your application, you may want to use the Clear

Western Digital method before transferring. The following example uses both of these

Music methods:<HTML>

Networks <BODY>

Toner .

Cheap Laptops .

Wholesale .

Brother <%

Netvista If Request("CustomerStatus") = "" Then

Camera Response.Clear

Networking Server.Transfer("/CustomerInfo/Register.asp")

Sharp Else

Cheap Response.Write "Welcome back " & Request("FirstName") & "!"

Windows .

Monitors .

Linux .

Computer Support End If

Used Laptops %>

Cameras </BODY>

Scanners </HTML>

Panasonic You could also use Response.Buffer to prevent the Web server

Workstation from returning the HTTP header before a script can modify the header. Certain

Iseries properties and methods, such as Response.Expires and

Backup Response.Redirect, modify the HTTP header.

Information Technology If the Buffer property in a script is set to TRUE without

Routers also calling the Flush method to immediately send buffered

180gxp content to the browser, the server will maintain Keep-Alive requests made by the

Notebook Battery client. The benefit of writing scripts in this manner is that server performance

Security is improved because the server does not have to create a new connection for each

Lotus client request (assuming that the server, client, and any proxy servers all

Virus support Keep-Alive requests). However, a potential drawback to this approach is

Thinkpad T42 that buffering prevents the server's response from being sent to the user until

Thinkpad 600 the server has finished processing the entire script. For long or complicated

Thinkpad 600e scripts, users could experience long wait times before seeing the page.

Thinkpad 570 Buffering is turned on by default for ASP applications. You can use the

Thinkpad 600x to turn off buffering for an entire ASP application. For more information, see

Thinkpad 390x .

Thinkpad A31 Your application may be sending pages to a client through a proxy

Thinkpad X20 server. A proxy server acts on behalf of client browsers to request pages

Bios Update from Web sites. The proxy server caches HTML pages so that repeated requests for

Laptops the same page can be returned quickly and efficiently to browsers. Having the

Toshiba proxy server process requests and cache pages reduces the load on the network

Laptop Battery and on the Web server.

Thinkpad Although caching works well for many HTML pages, it often does not work well

Microsoft for ASP pages that contain frequently updated information. For example, pages

Laptop Computers that report stock market prices or display inventory for a high-volume business

Laptop Computer must provide timely information. Information that is even one hour old might not

Desktop Computer be accurate enough. If your application returns personalized information, such

Notebooks as a custom home page, you want to ensure that no user sees another user's

Lenovo personal information.

Hard Drive By default, ASP instructs proxy servers not to cache the ASP page itself

Travelstar (although images, image maps, applets, and other items referenced from the page

Gateway are cached). You can allow caching for certain pages by using the

Laptop Parts Response.CacheControl property to set the Cache-Control HTTP

Software header field. The default value of Response.CacheControl is the

Hard Drives string "Private", which prevents proxy servers from caching the page. To allow

Electronics caching, set the Cache-Control header field to Public:<% Response.CacheControl = "Public" %>

Canon Because HTTP headers must be sent to the browser or proxy before any page

Desktop Pc content is sent, either put the Response.CacheControl property

Desktop Computers before any HTML tags or, if you have disabled buffering, use

Think Pad Response.Buffer to buffer the page.

Repair The Cache-Control header field is part of the HTTP 1.1 specification.

Data Recovery ASP pages are not cached on proxy servers that support only HTTP 1.0

Cisco because no Expires header field is sent.

Keyboard Each browser version has its own rules for determining whether to cache

Monitor pages. To prevent a browser from caching ASP pages, use

Desktop Response.Expires to set the Expires header:<% Response.Expires = 0 %>

Infosys A value of 0 forces cached pages to expire immediately. Because HTTP headers

Refurbished Laptops must be sent to the browser before any page content is sent, either put the

Wipro Response.Expires property before any HTML tags or buffer the

Lap Top page.

Refurbished A channel is a Web technology available with Microsoft Internet

Memory Explorer 4.0, or later, that you can use to automatically deliver new or

Intel updated Web content to users. The channel schedules the user's computer to

As400 periodically connect to a server and retrieve updated information. (This

Averatec retrieval process is commonly referred to as client pull because

Hardware information is "pulled" in, or gathered, from the server.) When new information

Dual Xeon is made available at a particular Web site, the content is downloaded to the

Storage browser cache for offline viewing. Clever use of channels for distributing Web

Seagate based information (especially on intranets) can help to centralize information

Computer Sales as well as reduce server traffic. For more information about channels, visit the

Computer Hardware Microsoft Internet Explorer Web site, at .

Printers Using ASP, you can write scripts that dynamically create channels by

Technology generating a channel definition file. An XML-based channel definition

Mainframe file (.cdf) describes the organization and update schedule of a channel's

Samsung contents. Commands in the .cdf file use syntax similar to HTML tags, so they are

Computer Repair easy to learn and to generate from a script. When you write a server-side script

Used Computers to create a channel definition file, give the file a .cdx extension. When ASP

Network reads a file with a .cdx extension, it automatically sends the application/x-cdf

Digital Cameras content type, which tells the browser to interpret the bytes as channel

Desktops definitions. If you do not use the .cdx extension, your script must manually set

Cognos the content type to application/x-cdf by using

Hosting Response.ContentType.

Netfinity Here is an example of how you might use channels. The following HTML form

Internet asks the user to select channels. When submitted, the form calls a script in a

Cheap Computer .cdx file to create the channel definitions.<P> Choose the channels you want. </P>

Digital Camera <FORM METHOD="POST" ACTION="Chan.cdx">

Printer <P><INPUT TYPE=CHECKBOX NAME=Movies> Movies

Xseries <P><INPUT TYPE=CHECKBOX NAME=Sports> Sports

Maxtor <P><INPUT TYPE="SUBMIT" VALUE="SUBMIT">

Data Storage </FORM>

Hitachi The script in Chan.cdx builds the channel definitions based on the form

Rational values submitted with the request.<% If Request.Form("Movies") <> "" Then %>

Websphere <CHANNEL>

Battery channel definition statements for the movie pages

It Support </CHANNEL>

Western Digital <% End If %>

Music <% If Request.Form("Sports") <> "" Then %>

Networks <CHANNEL>

Toner channel definition statements for the sports pages

Cheap Laptops </CHANNEL>

Wholesale <% End If %>

Brother Distributed Authoring and Versioning (WebDAV), a powerful extension of the

Netvista HTTP 1.1 protocol, exposes Web file storage mediauch as a local file

Camera systemver an HTTP connection. WebDAV holds great promise for making the Web

Networking into seamless, collaborative authoring environment. With the IIS 5.0

Sharp implementation of WebDAV, you can enable remote authors to create, delete, move,

Cheap search, or apply attributes to files and directories on your Web server. For

Windows more information, see .

Share this:

Add To Yahoo MyWeb Add To Google Bookmarks Add To Furl Fav This With Technorati Add To Newsvine Add To Bloglines Add To Ask Add To Windows Live Add To Slashdot Stumble This Digg This Add To Del.icio.us Add To Reddit

More about:

Aug September 2008 Oct
Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30        

IBM Computer, Laptops and Servers Blog on Technorati Related Blog of IBM Computer, Laptops and Servers on Sphere
Content Directory
Resource Guide


Inkbox Online Inkbox Replacement Inkjet Cartridges

Website Links
IBM Computer, Laptops and Servers Copyright © 2008 www.ibmfans.com. All rights reserved. Site Map
Homepage | Blog | Advertise | Privacy Policy | Disclaimer | Contact Us | Links