This discussion is archived
1 Reply Latest reply: Oct 22, 2013 10:42 PM by jnejedly RSS

WebLogic, Cannot display PDF in JSP

jnejedly Newbie
Currently Being Moderated

Hi,

we have a web application deployed on Oracle Application server (10.1.3.5.0). We deployed the same

app on WebLogic server (10.3.6.0) and now we have problem with displaying PDF on web page. Here is our code

 

<%@ page contentType="text/html;charset=windows-1250"%>

<%@ page import="java.io.ByteArrayOutputStream, java.io.DataOutput, java.io.DataOutputStream, ..." %>

<html>

  <head>

    <meta http-equiv="Content-Type" content="text/html; charset=windows-1250">

    <title>PDF</title>

  </head>

  <body>

    <%

      response.setContentType("application/pdf");

      IVystup vystup = (IVystup)session.getAttribute("IVystup");

      ByteArrayOutputStream buffer = makePDF(); // our method making pdf

      DataOutput output = new DataOutputStream(response.getOutputStream());

      byte[] bytes = buffer.toByteArray();

      response.setContentLength(bytes.length);

      for( int i = 0; i < bytes.length; i++ ) {

        output.writeByte( bytes[i] );

      }

    %>

  </body>

</html>

 

WebLogic reports "File is corrupted and cannot be repaired. Local\EWH&4u}ik5v".

 

We have latest Acrobat Reader. Tried a few IE (have version 10) reccomendations -

increase tmp size, delete temp files on leaving IE. But nothing worked.

Do you have any experience with WebLogic ? Could it be something wrong in above code ?

 

Thanks

  • 1. Re: WebLogic, Cannot display PDF in JSP
    jnejedly Newbie
    Currently Being Moderated

    I found it myself - the JSP must not contain any HTML code and must look like this

     

    <%@ page import="java.io.ByteArrayOutputStream, java.io.DataOutput, java.io.DataOutputStream, ..." %><%

          response.setContentType("application/pdf");

          ByteArrayOutputStream buffer = makePDF(); // our method making pdf

          DataOutput output = new DataOutputStream(response.getOutputStream());

          byte[] bytes = buffer.toByteArray();

          response.setContentLength(bytes.length);

          for( int i = 0; i < bytes.length; i++ ) {

            output.writeByte( bytes[i] );

    %>

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points