BBjHttpResponse::setFile

Description

In BBj 14.0 and higher, this method sets a file for download.

Syntax

Return Value

Method

void

setFile(string fileName)

Parameters

Variable

Description

fileName

the full/path/to/the/file

Return Value

None.

Remarks

The example below shows setting a file to be sent within a BBjServlet.

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!)
    request! = p_event!.getHttpRequest()
    response! = p_event!.getHttpResponse()
    response!.setFile("/tmp/foo.txt")
    response!.setHeader( "Content-Disposition", "attachment;filename=foo.txt")
    response!.setContentType("text/plain")
  methodend
classend

See Also

BBjAPI

BBjServletEvent

BBjHttpRequest

BBjHttpResponse