Documentation Center

Setting HTTP headers

HTTP headers are sent by the client in an HTTP protocol transaction. If your Web site personalizes content depending on these headers, you can handle this content by defining HttpHeader elements within an Identity element. The HttpHeader element defines an HTTP header Name and Value pair.

About this task

The following example defines HttpHeader elements for dealing with differing responses depending on the client user browser:

Procedure

  1. Create a JSP Page Template and add the following code (the code reads the details of the user agent (browser) being used):
    <html>
      <head><title>Browser Information</title></head>
      <body>
       <div>
        <% 
           String ua = request.getHeader( "User-Agent" );
           boolean isFirefox = ( ua != null && ua.indexOf( "Firefox/" ) != -1 );
           boolean isMSIE = ( ua != null && ua.indexOf( "MSIE" ) != -1 );
           response.setHeader( "Vary", "User-Agent" );
        %>
        <% 
            if( isFirefox ){ 
        %>
        <p>You are using Firefox</p>
        <% } else if( isMSIE ){ %>
    
        <p>You are using Internet Explorer</p>
        <% } else { %>
        <p>You are using neither Firefox nor Internet Explorer</p>
         <% } %>
       </div>
    
    <p><font face="Arial" size="3"><b>Browser Information</b></font></p>
    <hr align="left" width="30%" color="#04ACB5">
    <div align="left">
    <table border="0" width="44%">
    <%
    String browserVersion = request.getHeader("User-Agent");
    %>
         <tr>
           <td width="34%">Browser</font></td>
           <td width="4%">:</font></td>
           <td width="66%"><%= browserVersion %></font></td>
         </tr>
       </table>
      </div>
     </body>
    </html>
  2. Create a Page that uses this Page Template.
  3. Open the cd_archivemanager_conf.xml file in a text editor:
  4. In the <Capture> step, add the following:
    • an HttpHeader element to the DefaultIdentity that captures content for Internet Explorer only
    • an HttpHeader element to an Identity named Firefox that captures content for Firefox only
    • an Identity named Other Browser that captures content for browsers other than Internet Explorer and Firefox (no HttpHeader element defined)
    <Identity Name="Internet Explorer">
      <HttpHeader Name="User-Agent" Value="Mozilla/4.0 (compatible; MSIE 7.0; 
                   Windows NT 5.1; YPC 3.0.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"/>
    </Identity>
    
    <Identity Name="Firefox">
      <HttpHeader Name="User-Agent" Value="Mozilla/5.0 (Windows; U;
                   Windows NT 5.2; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0"/>
    </Identity>
    
    <Identity Name="Other Browser">
    </Identity>
  5. When you publish the Page, you can view the different profiles in the Archive Manager Explorer. The following image shows the browser information that is stored for the profiles: