400 users using DBSP now!
home -> documentation -> language reference -> HEADER tag


Description

The header element let you alter the values contained in the HTTP response header just before being sent back to the Web browser.


Syntax

<#HEADER NAME="aname" VALUE="avalue"/>

NAME Indicate in aname the name of the header field that you want to send back to the browser.
VALUE Indicate avalue the value of the header field that you want to send back to the browser.

Applications

The HEADER tag is useful when you want to alter the response header sent back to the browser for any particular reason. This could be, when you want to avoid that a web page remains stored on the web browser cache or when you want to tell the browser that display the save as dialog box instead of showing the contents of a file build at runtime.

The response header is explained with detail in the document: HTTP 1.1 specification RFC-2616


Examples

Example 1. Avoiding the web browser cache.

Suppose that you have a web page that reflects last moment information and you want to be sure that this page is always retrieved from the web server (not from the web browser cache) even when the user press the back button. This example shows you how.

Source code


File: examples/NoCache.dbsp


 
<#HEADER NAME="Cache-Control" VALUE="no-cache,no-store"/>


  

Avoiding the web browser cache


  

  

<#SP_TIME/>


   Look at the current time. Press here and then press back on your browser. 
   If the page is not stored on the cache then it will be reloaded from the server and the 
   time should change.
 




File: examples/NoCache1.dbsp



 

  

Avoiding the web browser cache


  

   Press the back button or press here to return to the previous page.
 


Test example


Example 2. Constructing dynamically a CSV file for download.

Suppose that you want to construct a CSV file based on some information of the database and let the user to download it. This example shows how to do it.

Source code


File: examples/csvfile.dbsp
/* This is a CSV file constructed at runtime with DBSP */
<#HEADER NAME="Content-Disposition" VALUE='attachment; filename="country.csv"'/>
Country code, Country, Population, Gross National Income, Purchase Power
<#DATASET ALIAS="OPEX" QUERYID="3">
<#COUNTRYCODE/>,"<#COUNTRY/>",<#POPULATION/>,<#GNI/>,<#PPP/><#/DATASET>

Test example