Hello, maybe this helps:

...
<a target="_blank" href="openfile.jsp?doc_id=1&size=50000&origname=myfile.pdf>file</a>
...


openfile.jsp:

<[EMAIL PROTECTED] import="java.io.*"%><%
   response.reset();
   response.setContentType(request.getParameter("content_type"));
response.setContentLength(Integer.parseInt(request.getParameter("size"))); response.setHeader("Content-Disposition", "inline; filename=" + request.getParameter("origname")); response.setHeader("Expires",new java.util.Date(new java.util.Date().getTime()+1000000).toString()); BufferedInputStream in = new BufferedInputStream(new FileInputStream(request.getParameter("origname")));
   ByteArrayOutputStream byteStream = new ByteArrayOutputStream(512);
   int imageByte;
   while((imageByte = in.read()) != -1) {
       byteStream.write(imageByte);
   }
   in.close();
   byteStream.writeTo(response.getOutputStream());
%>



Shoukat, Faisal wrote:
Hi All,

I am wanting to know how to display an uploaded document from clicking on a
link on my JSP.  I have managed to save the document into the database, and
I can load the document from the database.

When I click to open the document I have to save it to my file system first
then open it.  Has anyone got any example of how to just click on the
document and it opens another window which shows the contents.

For example if it was a word documents that I saved, clicking on it would
open up the document in a word window

Thanks in advance

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to