Link to home
Start Free TrialLog in
Avatar of arichexe
arichexe

asked on

Display blob JSP that mimics ASP

How could I modify the below JSP to mimic the ASP, so it simply displays the blob without having to write it to a file first?
 
// Display Blob JSP
PreparedStatement ps = MyConn.prepareStatement("SELECT MyBlob FROM MyTable");
ResultSet rs = ps.executeQuery();
if (rs.next()) {
  Blob b = rs.getBlob(1);
  BufferedOutputStream os;
  File f = new File("MyFile.pdf");
  os = new BufferedOutputStream(new FileOutputStream(f));
  os.write(b.getBytes(1,(int) b.length()),0,(int) b.length());
  os.flush();
  os.close();
  out.print("<script language=javascript>self.location.replace('MyFile.pdf');</script>\n");
}
 
' Display Blob ASP
Set rs = MyConn.Execute("SELECT MyBlob FROM MyTable")
If Not rs.EOF Then
  Response.ContentType = "application/pdf"
  Response.BinaryWrite rs("MyBlob")
End If
ASKER CERTIFIED SOLUTION
Avatar of rrz
rrz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial