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("S ELECT 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.l ocation.re place('MyF ile.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
// Display Blob JSP
PreparedStatement ps = MyConn.prepareStatement("S
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
os.flush();
os.close();
out.print("<script language=javascript>self.l
}
' 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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.