BBjspWebResponse::getHeaders


Description

In BBj 16.0 and higher, this method returns a BBjVector containing all the values of the specified header from the BBjspWebResponse object.

Syntax

Return Value

Method

BBjVector

getHeaders(string name)

Parameters

Variable

Description

name

Specifies the name of the header.

Return Value

a BBjVector containing the values for the header

Remarks

The example below shows getting all the values of the Accept-Encoding header from a response within a BBJSP Servlet.

Example

This example demonstrates how this works in a BBJSP web-page

<!DOCTYPE html/>
<%@ taglib uri='/WEB-CFG/tld/core.tld' prefix='c' %>
<html>
    <body>
        <ul>
            <c:iterate data="<%= #getResponse().getHeaderNames() %>" id="headerName">
                <li><b>HEADER: ${headerName}</b>
                <%
                    REM = Get the "headerName" from the page context
                    hName$ = #PageContext!.getAttribute("headerName")
                %>
                <ul>
                <c:iterate data='<%= #getResponse().getHeaders(hName$) %>' id='headerValue' >
                    <li>${headerValue}
                <c:iterate>
                </ul>
            </c:iterate>
        </ul>
    </body>
</html>

This example demonstrates how this works in a BBJSP servlet

class public MyServlet

  field private BBjspWebRequest request!
  field private BBjspWebResponse response!
  field private BBjspWebSession session!
  
  method public void service(BBjspServletContext context!)
       
    #request! = context!.getRequest()
    #response! = context!.getResponse()

    #response!.setContentType("text/html")
    s! = #response!.getOutputStream()
    
    s!.write("<html><body><h1>Hello from BBJSP</h1>")
    s!.write("Accept-Encoding:")
    values! = #response!.getHeader("Accept-Encoding")
    if values!.size() then
      for i = 0 to values.size()-1
        s!.write(values!.get(i))
        s!.write("<br>")
      next i
    endif
    s!.write("</body></html>")
  methodend
classend

See Also

BBJSP

BBjspWebRequest

BBjspWebResponse

BBjVector