BBjspPageContext::getLogger (Deprecated)

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

Description

In BBj 16.0 and higher, this method obtains an instance of the BBjspLogger class to allow components to write to the log file for the current BBjJettyContext.

Syntax

Return Value

Method

BBjspLogger

getLogger()

Parameters

None.

Return Value

the BBjspLogger object for the current BBjJettyContext

Remarks

Example

This example demonstrates how this works in a BBJSP widget

REM ===
REM === A BBjspWidget that counts page-visits for the user.
REM ===

class public PageCounterWidget implements BBjspWidget

  method public void open(BBjspPageContext context!)

    declare BBjspWebRequest request!
    declare BBjspWebSession session!
    declare BBjspSessionData data!
    declare BBjspLogger logger!
    declare BBjspHashMap visitMap!

    request! = context!.getRequest()
    session! = context!.getSession()
    data! = context!.getBBjspSession()
    logger! = context!.getLogger()

    url$ = request!.getRequestURL()
    
    if !data!.contains("PAGE_VISITS") then
      data!.setAttribute("PAGE_VISITS",BBjAPI().makeBBJSP().makeBBjspHashMap())
    endif
    
    visitMap! = data!.getAttribute("PAGE_VISITS")
    
    ct = 0

    if visitMap!.containsKey(url$) then
      ct = num(visitMap!.get(url$))
    endif

    ct = ct + 1
    visitMap!.put(url$,str(ct))
    
    logger!.log(url$ + " VISIT COUNTER : " + str(ct))
    
    context!.saveBBjspSession()
    
  methodend

classend

See Also

BBJSP

BBjspPageContext

BBjspHashMap (Deprecated)