BBjspWebRequest::setAttribute (Deprecated)

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

Description

In BBj 16.0 and higher, this method stores an attribute in this BBjspWebRequest. Attributes are reset between requests. This method is most often used in conjunction with BBjspWebResponse::sendRedirect.

Attribute names should follow the same conventions as package names. If the object passed in is null(), the effect is the same as calling BBjspWebRequest::removeAttribute(String).

Syntax

Return Value

Method

void

setAttribute(string name, Object value)

Parameters

Variable

Description

name

a String specifying the name of the attribute

value

the Object to be stored

Return Value

None.

Remarks

None.

Example

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

<html>
    <body>
        <h1>Hello from BBJSP</h1>
        Foo:<%= str(#getRequest().getAttribute("foo")) %>
    </body>
</html>

This example demonstrates how this works in a BBJSP servlet

class public FooServlet

  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! = context!.getResponse()

    #request!.setAttribute("foo","'foo' was set in FooServlet")
    
    #response!.sendRedirect("/path/to/another/page.bbjsp")
    
  methodend

classend

See Also