Read the file from its location into a byte[]  in your Action and then write
the bytes to the response stream and return null from the Action's execute
method (rather than an ActionForward).

byte[] buffer ....// read file into a byte[]

response.setContentType("application/x-pdf");
response.setContentLength(buffer.length);
response.setHeader("Content-disposition", "inline; filename=xyz.pdf");

ServletOutputStream output = response.getOutputStream();
output.write(buffer);
output.flush();

return null;


Niall

----- Original Message ----- 
From: "Mike Elliott" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, September 17, 2004 3:26 AM
Subject: Making a file available?


> I have an application which gathers information about internal
> processes.  Some of this information is in the form of a text file, an
> Excel file, a PDF file, etc.
>
> What I need to be able to do is to make a URL available to users which
> will provide a requested file to a user; that is, if the URL refers to a
> PDF file then when a user makes that request, his browser will detect
> that the request was for a PDF file and properly render it in xpdf or
> acrobat or whatever.
>
> For example, if a user entered the url
>
> http://www.blip.org/getFile.do?name=xyz.pdf
>
> the result would be his browser properly displaying the contents of
> xyz.pdf.
>
> Is this even possible?  If so, how would I go about doing it?  We can
> assume that the server knows where to find any named file and
> furthermore that it knows the MIME type of the file (in this case
> application/x-pdf).
>
> Any ideas?



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

Reply via email to