BBjHttpRequest::getBody

Description

In BBj 14.0 and higher, this method returns a BBjString object which contains the body of a POSTed request to a servlet.

Syntax

Return Value

Method

string

getBody()

Parameters

None.

Return Value

Returns a string object.

Remarks

The example below demonstrates how to read the request body in a servlet.

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()

    resp!.setContentType("text/html")

    open(chan)"JSERVLET"

    print(chan)"<html><body><h1>Hello BBj!</h1>"

    xml$ = request!.getBody()

    print(chan)"You uploaded the following XML '"

    print(chan)xml$

    print(chan)"'"

    print(chan)"</body></html>"

    close(chan)

  methodend

classend

See Also

BBjAPI

BBjServletEvent

BBjHttpRequest

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.