In the below example did you send a request parameter through of name
content_type too. With a value of pdf or msword etc???

-----Original Message-----
From: Avramucz István [mailto:[EMAIL PROTECTED] 
Sent: 12 May 2006 13:34
To: Struts Users Mailing List
Subject: Re: displaying document in pop up window

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]


----------------------------------------------------------------------------
-------- 
The Northgate IS Content Screening and Inspection system has scanned this 
message for malicious and inappropriate content and none was found. Please
take care 
when opening attachments even when these are expected and from known and
trusted 
sources. 
----------------------------------------------------------------------------
--------

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

Reply via email to