Content-Disposition inline Not working
843835Feb 15 2002 — edited Apr 29 2002Hi all,
I am using Orion application server as Web server. I like to open a file in client side form the server. Which one is known MIME type. I don't want the IE to prompt the user for Save as/ Open from the current location.
I am using "inline" argument in Content-Disposition header. Eventhough i am getting promt dialog box in client side.
The following is my code.
<%@ page import="java.io.*" %>
<%@ page import="java.net.*" %>
<% response.setContentType("application/pdf"); %>
<% response.setHeader("Content-Disposition" , "inline;filename=test.pdf" ); %>
<%
String fileURL = "http://java1/examples/jsp/test.pdf";
ServletOutputStream sout = response.getOutputStream ();
URL url = new URL ( fileURL );
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
URLConnection conn = url.openConnection();
// Use Buffered Stream for reading/writing.
bis = new BufferedInputStream(conn.getInputStream());
bos = new BufferedOutputStream(sout);
byte[] buff = new byte[2048];
int bytesRead;
// Simple read/write loop.
while(-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
bos.write(buff, 0, bytesRead);
}
}
catch(Exception ex){
System.out.println(ex.toString());
}
%>
Any one give the soloution for this problem. I hope there is no problem with the source code. I want to avoid the dialog box while downloading in the client side.
Thanks
Prabhu.