BBjspObjectSerializer::decodeToStream (Deprecated)

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

Description

In BBj 16.0 and higher, this method decodes a Base-64 encoded string and writes the result to the supplied OutputStream.

Syntax

Return Value

Method

void

decodeToStream(string base64, OutputStream stream)

Parameters

Variable

Description

base64

a string containing Base-64 encoded data

stream

the OutputStream to write to

Return Value

None.

Remarks

None.

Example

rem '===
rem '=== This Servlet extracts an image from a database and sends the result back to the client browser
rem '===

class public GetImage

    method public void service(BBjspServletContext context!)
        declare BBjspWebRequest request!
        declare BBjspWebResponse response!

        db$ = context!.getParameter("DATABASE")

        request! = context!.getRequest()
        response! = context!.getResponse()

        sql$ = "SELECT * FROM IMAGES WHERE IMAGE_ID=?"

        ch=sqlunt
        sqlopen (ch)db$
        sqlprep (ch)sql$
        sqlexec (ch)request!.getParameter("image_id")

        dim x$:sqltmpl(ch)
        x$=sqlfetch(ch,ERR=NO_IMAGE)

        img$ = x.IMAGE_DATA$
        response!.setContentType("image/png")

        BBjspObjectSerializer.decodeToStream(img$,response!.getOutputStream())

NO_IMAGE:
    sqlclose(ch)
methodend

classend

See Also