Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Content-Disposition inline Not working

843835Feb 15 2002 — edited Apr 29 2002
Hi 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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 27 2002
Added on Feb 15 2002
2 comments
876 views