BBjspWebRequest::getCookies (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 BBjCookie objects from the BBjspWebRequest object.

Syntax

Return Value

Method

BBjVector

getCookies()

Parameters

None.

Return Value

a BBjVector containing the BBjCookie objects

Remarks

None.

Example

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

<%@ taglib uri='/WEB-CFG/tld/core.tld' prefix='c' %>
<html>
    <body>
        <h1>Hello from BBJSP</h1>
        <ul>
        <c:iterate data='<%= #getRequest().getCookies() %>' id='cookie'>
            <%
              cookie! = #PageContext!.getAttribute("cookie",err=*next)
            %>
            <li>
                The Cookie '<%= cookie!.getName() %>'
                has the value '<%= cookie!.getValue() %>'
                for the domain <%= cookie!.getDomain() %>
                at path <%= cookie!.getPath() %>
                will expire in <%= cookie!.getMaxAge() %> seconds
                is version <%= cookie!.getVersion() %>
                comment '<%= cookie!.getComment() %>'
        </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>")
    vCookies! = #request!.getCookies()
    sz = vCookies!.size()
    if sz then
      s!.write("<ul>")
      for i = 0 to sz-1
        cookie! = vCoolies!.get(i)
        s!.write("<li>")
        s!.write("The BBjCookie '" + cookie!.getName() + "' ")
        s!.write("has the value '" + cookie!.getValue() + "' ")
        s!.write("for the domain " + cookie!.getDomain() + " ")
        s!.write("at path " + cookie!.getPath() + " ")
        s!.write("will expire in " + cookie!.getMaxAge() + " seconds ")
        if cookie!.isSecure()
          s!.write(" for HTTPS protocol ")
        endif
        s!.write("is version " + cookie!.getVersion() + " ")
        s!.write("comment '" + cookie!.getComment() + "' ")
      next i
      s!.write("</ul>")
    endif
    s!.write("</body></html>")
  methodend
classend

See Also

BBJSP

BBjspWebRequest

BBjVector

BBjCookie