4

Is there a way to override the content disposition header for an attachment opened through an xPage URL? I am attempting to open attachments/pdf's in the browser as opposed to the default which is to download/save.

This question was also asked on Wissel's site by Mark Leusink, but I couldn't find an answer.

1

1 Answer 1

4

There are two approaches you can take:

  • Use an XAgent to read the attachment stream instead of linking to the attachment directly. There you can use the following to overwrite attachment/inline and file name.
response.setContentType("text/xml");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("content-disposition", "inline; Filename=invoice.pdf");
  • Be nice to your admin and use a web site rule to overwrite the HTTP header for your attachment urls. No code change in your application required and can be on a per application base

HTH :-) stw

6
  • Thanks for the help. I will try both of these approaches. Can see some advantages with each. May 28, 2013 at 16:13
  • I am having trouble with both of these examples. Do you know of any examples I can crib? Maybe one on your site, which I lean on frequently. May 29, 2013 at 0:47
  • for approach 1: update your question with the code you tried. The trick there is copying an inputstream (the attachment) to an outputstream (the XAgent response) - Apache Commons has ready classes for that. But I would go down the route of web site rule (a header rule is what you need). Which rule did you try?
    – stwissel
    May 29, 2013 at 1:27
  • I tried the HTTP response headers, then tried adding contentType, Cache-Control and content-disposition in the custom header. Not sure where to test that out to see if it works, but the change failed (after restarting http). May 29, 2013 at 2:26
  • Did you check what actually got transmitted over the wire?
    – stwissel
    May 29, 2013 at 7:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.