BBjHttpResponse::encodeURL (Deprecated)

BBjHttpResponse::encodeURL is deprecated for BBj 21.00 and higher, and has been replaced by BBxServletResponse::encodeURL.

Description

In BBj 12.00 and higher, this method encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged. The implementation of this method includes the logic to determine whether the session ID needs to be encoded in the URL. For example, if the browser supports cookies, or session tracking is turned off, URL encoding is unnecessary.

For robust session tracking, all URLs emitted by a servlet should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.

Syntax

Return Value

Method

string

encodeURL(string url)

Parameters

Parameter

Description

url

the url to be encoded.

Return Value

the encoded URL if encoding is needed; the unchanged URL otherwise.

Remarks

The example below shows encoding a URL for redirect

Example

rem 'Obtain the instance of the BBjAPI object

let myAPI! = BBjAPI()
MyServlet! = new MyServlet()

data!.setCallback(data!.ON_WEB_CONNECTION, myServlet!, "myMethod")

process_events
class public MyServlet
    method public void myMethod(BBjServletEvent p_event!)
        let chan = UNT
        request! = p_event!.getHttpRequest()
        response! = p_event!.getHttpResponse()
        response!.setContentType("text/html")
        open (chan)"JSERVLET"
        print (chan)"<html><body><h1>Hello BBj!</h1>"
        print (chan)"<a href = '"
        print (chan)response!.encodeURL("/servlet/anotheServlet?wibble = 123")
        print (chan)"'>Click</a>"
        print (chan)"</body></html>"
        close (chan)
    methodend
classend

See Also

BBjAPI

BBjServletEvent

BBjHttpRequest

BBjHttpResponse