The <ISBINARY>
tag allows you to define templates that generate binary pipeline output. This makes it possible, for example, to return PDF documents or image files as pipeline result.
In a template, the <ISBINARY>
tag can only be combined with tags that affect the HTTP header, such as <ISCONTENT>
and <ISCACHE>
. All text content is ignored.
Note
The ISML designer is responsible, to set the correct <ISCONTENT>
MIME type in a template using <ISBINARY>
.
<isbinary ( file = "( {String} | {ISML expression} )" | stream = "{ISML expression}" | resource = "( {String} | {ISML expression} )" | byte = "{ISML expression}" ) [ downloadname = "( {String} | {ISML expression} )" ] >
The following sample reads the content from a pdf file and sends it as response:
<ISBINARY file="d:/foobar.pdf"/>
The next sample reads the content from an InputStream and sends it as response:
<ISBINARY stream="#aStreamObject#"/>
The next sample reads the content from a resource found in the classpath and sends it as response:
<ISBINARY resource="com/intershop/beehive/core/dbinit/internal/icon.gif"/>
Finally, the sample below sends a byte array as response, e.g. can be read from a persistent object (blob):
<ISBINARY bytes="#MyObject:bytes#"/>
Next, a complete ISML template example is shown. The template returns a PDF documents which is read from the file foobar.pdf
. Note that the content is made cacheable.
<ISCONTENT type="application/pdf"> <ISCACHE type="relative" hour="24"> <ISBINARY file="D:/foobar.pdf"/>
If the optional "downloadname" attribute is set, a header like:
response.setHeader("Content-Disposition", "attachment; filename=\""downloadname"\"");
is generated into the JSP code. The header is used to force the browser to display a file download dialog with the given download file name.
Note
Make sure that the content type is set to something different than "text/html" or "image/gif" (e.g. <iscontent type="application/octet-stream">
) because some browsers first evaluate the content type and display the content instead of offering a download dialog as desired.
Typically, templates generating binary pipeline output are included in other templates. For example, assume the snippet above defines a template referenced by the interaction end node of the pipeline BinaryOutput-PDF
. In a different template, you can then create a link to the document foobar.pdf
by calling the pipeline as shown below:
<iscontent type = "text/html"> This is text <a href="#URL(Action('BinaryOutput-PDF'))#">View the foobar.pdf file</a> This is text
One of the following attributes is required.
file
file = filename | ISML expression
Specifies a filename referencing a binary file, e.g. an image, to be read and sent as response.
stream
stream = ISML expression
Specifies a java.io.InputStream object to be read and sent as response.
resource
resource = string | ISML expression
Specifies a binary resource found in the classpath, e.g., com/intershop/beehive/core/dbinit/internal/icon.gif.
bytes
bytes = ISML expression
Specifies a bytes array (bytes) object containing binary content to be read and sent as response.