<%@ page language="java"
%><%@ page import="xxas.oracle.apps.xxas.com.ServiceManager"
%><%! public static final String SVN_ID = "$Id$";
%><%
  // Force character encoding to UTF8
  request.setCharacterEncoding("UTF-8");
  
// Commented out because cache expiration headers cause Flex in IE6 to
// bomb out when on HTTPS.
// response.setHeader("Cache-Control", "no-cache"); //HTTP 1.1
// response.setHeader("Pragma", "no-cache"); //HTTP 1.0
// response.setDateHeader("Expires", 0); //prevents caching at the proxy server
%><%

  // Instantiate a new service manager
  ServiceManager srvMgr = new ServiceManager();

  // Invoke the service
  byte[] outputData = srvMgr.invokeBlobQuery(request, response);

  // Retrieve additional attributes
  String mimeType = srvMgr.getMimeType();
  String fileName = srvMgr.getFileName();
  String inlineOrAttachment = srvMgr.getInlineOrAttachment();

  // Verify details were returned
  if (outputData != null && mimeType != null && fileName != null &&
      inlineOrAttachment != null) {

    // Set the MIME type
    response.setContentType(mimeType);

    // Set the Content Disposition
    String cd;
    if ("I".equals(inlineOrAttachment)) {
      cd = "inline";
    } else {
      cd = "attachment";
    }
    cd = cd.concat(";filename=").concat(fileName);
    response.setHeader("Content-Disposition", cd);

    // Stream the blob to the response
    OutputStream op = response.getOutputStream();
    op.write(outputData);
    op.flush();
    op.close();
  }

%>
