0 Replies Latest reply: Nov 26, 2012 9:55 PM by udflyerfan9498 RSS

    Viewing document (blob) in JSP doesn't work

      I am currently supporting an application which talks to an Oracle 11gR1 database using several application servers. Our application is working on the following application servers:
      - Apache Tomcat 5 and 6
      - Oracle Application Server 10gR3
      - WebLogic (configuration 1)

      We have an second server which has WebLogic (configuration 2); however, we cannot get the JSP to display on that server. The same WAR file has been deployed to all four application servers, yet only the WebLogic Server configuration 2 doesn't work.

      WebLogic Server (configuration 2) appears to work (doesn't give an error message); however, the web-page tries to show a document (which appears to be a copy/representation of the existing HTML web page - i.e. a form filter screen). Any insight into the possible problem?

      The code we are using is shown below:

      public ActionForward execute(ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) throws Exception {

      String fileIdString = request.getParameter("fileIdString");

      try {

      // Get the File to send to the client
      int fileId = Integer.parseInt(fileIdString);
      CustomFile file = fileService.loadFileById(fileId);

      if (file == null) {
      log.error("The fileId (" + fileId + ") could not be found - DNE.");

      int lastDot = file.getFilename().lastIndexOf('.');
      String fileExtension = (lastDot!=-1 ? file.getFilename().substring(lastDot) : "" );
      FileType fileType = fileService.loadByFileExtension(fileExtension);

      if (fileType == null) {
      log.error("The system could not find the file extension (" + fileExtension + ").");

      // Setup the response header so a file can be streamed to the client
      response.setHeader("Content-disposition", "attachment; filename=" + file.getFilename());
      response.setContentLength((int) file.getFile().length());

      // Break the file down into its bytes so it can be streamed
      ServletOutputStream outputStream = response.getOutputStream();
      InputStream inputStream = file.getFile().getBinaryStream();

      byte[] buffer = new byte[2048];
      int bytesRead = inputStream.read(buffer);
      while (bytesRead >= 0) {
      if (bytesRead > 0) {
      outputStream.write(buffer, 0, bytesRead);
      bytesRead = inputStream.read(buffer);

      // Garbage collection

      return null;

      } catch (Exception exception) {
      return mapping.findForward("failure");


      We had a siimilar issue with some displaying RTF documents and the solution was to remove ALL whitespace characters in the JSP (which seemed to work). I don't see how we can remove the whitespace in the above ActionServlet code.

      Thanks in advance for the help!