Re: Problem With Forwarding to a non-HTML file

2002-01-31 Thread Mark Woon

"Tingleff, Sam" wrote:

> I've been working on this a little.  You can add a header:
>
> Content-Disposition: attachment; filename=mypdf.pdf
>
> Seems to work on ie 5.5, haven't tested other browsers.

Thanks, this did the trick.  Works in Netscape (Windows and Linux) as well.

-Mark



--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Problem With Forwarding to a non-HTML file

2002-01-30 Thread Thierry Cools

try something like this; it will open the pdf viewer in your browser



public class ShowDocumentAction extends BasicAction {
public ActionForward perform(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {

HttpSession session = request.getSession();
try {
Object object = session.getAttribute("BlobObject");
if (object != null) {
DocumentDetailModel detailModel =
(DocumentDetailModel)object;

ByteArrayOutputStream baos = new ByteArrayOutputStream();
Document document = new Document();

PdfWriter.getInstance(document, baos);// Using the
library of Bruno Lowagie  to convert xml to PDF

Parser parser =
ParserFactory.makeParser("org.apache.xerces.parsers.SAXParser");
parser.setDocumentHandler(new SAXiTextHandler(document));

ByteArrayInputStream stream = new
ByteArrayInputStream(detailModel.getDetail());  // this is an array of byte
InputSource inputSource = new InputSource(stream);
parser.parse(inputSource);

response.setContentType("application/pdf");
response.setContentLength(baos.size());
ServletOutputStream out = response.getOutputStream();
baos.writeTo(out);
out.flush();
}
}
catch (Exception ex) {
}
return "";
}
}

Best regards,
Thierry

- Original Message -
From: "Duncan Harris" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, January 30, 2002 10:18 PM
Subject: Re: Problem With Forwarding to a non-HTML file


> [EMAIL PROTECTED] (Mark Woon) wrote:
>
> > Sorry, I guess I should also have added that PDF files are ocassionally
> > generated on the fly., in which case there's really nothing to redirect
or
> > forward to.  Is there anything I can do in these situations?
>
> The Inland Revenue site in the UK does this, if you fancy filling
> in a dummy tax return to see how it works... :-)
> http://www.inlandrevenue.gov.uk/
> If you are interested you must go to the Self assessment then after
> creating a new forms log-in, select download and print locally.
>
> When I used to do CGI I used to do things with the extra path
> to fool the browser:  /cgi-bin/genpdf.exe/docname.pdf
> I think maybe something similar is possible with servlets.
>
> Duncan Harris
> ~~~
> Hartford, Cheshire, U.K., Tel: 07968 060418
> Looking for STRUTS contract work in the U.K.
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>


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




Re: Problem With Forwarding to a non-HTML file

2002-01-30 Thread Duncan Harris

[EMAIL PROTECTED] (Mark Woon) wrote:

> Sorry, I guess I should also have added that PDF files are ocassionally
> generated on the fly., in which case there's really nothing to redirect or
> forward to.  Is there anything I can do in these situations?

The Inland Revenue site in the UK does this, if you fancy filling
in a dummy tax return to see how it works... :-)
http://www.inlandrevenue.gov.uk/
If you are interested you must go to the Self assessment then after
creating a new forms log-in, select download and print locally.

When I used to do CGI I used to do things with the extra path
to fool the browser:  /cgi-bin/genpdf.exe/docname.pdf
I think maybe something similar is possible with servlets.

Duncan Harris
~~~
Hartford, Cheshire, U.K., Tel: 07968 060418
Looking for STRUTS contract work in the U.K.

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Problem With Forwarding to a non-HTML file

2002-01-30 Thread Tingleff, Sam


I've been working on this a little.  You can add a header:

Content-Disposition: attachment; filename=mypdf.pdf

Seems to work on ie 5.5, haven't tested other browsers.

-Original Message-
From: Mark Woon [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 30, 2002 11:22 AM
To: Struts Users Mailing List
Subject: Re: Problem With Forwarding to a non-HTML file



Sorry, I guess I should also have added that PDF files are ocassionally
generated on the fly., in which case there's really nothing to redirect or
forward to.  Is there anything I can do in these situations?


Max Cooper wrote:

> Sending a redirect to the PDF file might work better for your situation.
>
> -Max
>
> - Original Message -
> From: "Mark Woon" <[EMAIL PROTECTED]>
> To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> Sent: Tuesday, January 29, 2002 11:28 PM
> Subject: Problem With Forwarding to a non-HTML file
>
> > Hi all.
> >
> > I'm using an Action to figure out which document I need to serve, and
> > the document could be a pdf file.  The problem is that when I forward to
> > a PDF file, the browser still thinks that it's on the action (get.do),
> > and tries to save the file as get.do.  I've set the content-type so
> > it'll spawn the right app, but is there a way to specify the name with
> > which the file gets saved under?
> >
> > Thanks,
> > -Mark
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
~~Mark Woon~~~
If you're not part of the solution, you're part of the precipitate.



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




Re: Problem With Forwarding to a non-HTML file

2002-01-30 Thread Mark Woon


Sorry, I guess I should also have added that PDF files are ocassionally
generated on the fly., in which case there's really nothing to redirect or
forward to.  Is there anything I can do in these situations?


Max Cooper wrote:

> Sending a redirect to the PDF file might work better for your situation.
>
> -Max
>
> - Original Message -
> From: "Mark Woon" <[EMAIL PROTECTED]>
> To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> Sent: Tuesday, January 29, 2002 11:28 PM
> Subject: Problem With Forwarding to a non-HTML file
>
> > Hi all.
> >
> > I'm using an Action to figure out which document I need to serve, and
> > the document could be a pdf file.  The problem is that when I forward to
> > a PDF file, the browser still thinks that it's on the action (get.do),
> > and tries to save the file as get.do.  I've set the content-type so
> > it'll spawn the right app, but is there a way to specify the name with
> > which the file gets saved under?
> >
> > Thanks,
> > -Mark
>
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 

--
~~Mark Woon~~~
If you're not part of the solution, you're part of the precipitate.





Re: Problem With Forwarding to a non-HTML file

2002-01-30 Thread Marcus Brito

Em Qua, 2002-01-30 às 05:28, Mark Woon escreveu:

> I'm using an Action to figure out which document I need to serve, and
> the document could be a pdf file.  The problem is that when I forward to
> a PDF file, the browser still thinks that it's on the action (get.do),
> and tries to save the file as get.do.  I've set the content-type so
> it'll spawn the right app, but is there a way to specify the name with
> which the file gets saved under?

Do not use forward, but a redirect. If you're using the 
tag, remember to add the "redirect=true" attribute.

-- 
Ja ne,
   Pazu
   mailto: [EMAIL PROTECTED]

Anime Gaiden: de fãs para fãs, sempre.



signature.asc
Description: This is a digitally signed message part


Re: Problem With Forwarding to a non-HTML file

2002-01-30 Thread Max Cooper

Sending a redirect to the PDF file might work better for your situation.

-Max

- Original Message - 
From: "Mark Woon" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Tuesday, January 29, 2002 11:28 PM
Subject: Problem With Forwarding to a non-HTML file


> Hi all.
> 
> I'm using an Action to figure out which document I need to serve, and
> the document could be a pdf file.  The problem is that when I forward to
> a PDF file, the browser still thinks that it's on the action (get.do),
> and tries to save the file as get.do.  I've set the content-type so
> it'll spawn the right app, but is there a way to specify the name with
> which the file gets saved under?
> 
> Thanks,
> -Mark



--
To unsubscribe, e-mail:   
For additional commands, e-mail: