BBjspWebRequest::getHeaders (Deprecated)

The BBJSP system is deprecated. For new development, use BBxServlet.

Description

In BBj 16.0 and higher, this method returns the a BBjVector containing all the values for the specified header in the BBjspWebRequest object.

Syntax

Return Value

Method

BBjVector

getHeaders(string name)

Parameters

Variable

Description

name

the name of the header

Return Value

a BBjVector containing the header value(s)

Remarks

in most cases a header has only one value and using BBjspWebRequest::getHeader(String) would be the better option.
Use this method if you need to check for multiple values of the header.

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="<%= #getRequest().getHeaderNames() %>" id="headerName">
      <li><b>HEADER: ${headerName}</b>
      <ul>
      <%
        REM = Get the "headerName" from the page context
        hName$ = #PageContext!.getAttribute("headerName")
      %>
      <c:iterate data='<%= #getRequest().getHeaders(hName$) %>' id='headerValue' >
        <li>${headerValue}</li>
      </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()
    
    #session! = #request!.getSession()
    
    s!.write("<html><body><h1>Hello from BBJSP</h1>")
    vectHeaders! = #request!.getHeaders("Header")
    sz = vectHeaders!.size()
    if sz then
      s!.write("<ul>")
      for i = 0 to sz - 1
        s!.write("<li>" + vectHeaders!.get(i))
      next i
      s!.write("</ul>")
    endif
    s!.write("</body></html>")
  methodend
classend

See Also

BBJSP

BBjspWebRequest

BBjVector