BBjspWebSession::getAttributeNames (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 attribute names from the BBjspWebSession object.

Syntax

Return Value

Method

BBjVector

getAttributeNames()

Parameters

None.

Return Value

a BBjVector containing the names of stored attributess.

Remarks

The example below shows getting the attribute names and values from a request within a BBJSP BBJSP Servlet.

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="<%= #getSession().getAttributeNames() %>" id="name">
                <%
                    REM = Get the "name" from the page context
                    name$ = #PageContext!.getAttribute("name")
                %>
                <li><b>${name}</b> = <%= str(#getSessiont().getAttribute(name$)) %>
            </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()

    #session! = #request!.getSession()
    s! = #response!.getOutputStream()
    
    #response!.setContentType("text/html")
    
    s!.write("<html><body><h1>Hello from BBJSP</h1>")
    names! = #session!.getAttributeNames()
    if (names!.size()>0) then
      s!.write("<ul>")
      for i = 1 to names!.size()
        name$ = names!.get(i-1)
        s!.write("<li>"+name$ + ":" + session!.getAttribute(name$))
      next i
      s!.write("</ul>")
    else
      s!.write("<br/>No session variables!<br/>")
    endif
    s!.write("</body></html>")
  methodend
classend

See Also

BBjspWebSession

BBjVector