• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Displaying Binary Data Fetched with AJAX

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using an AJAX (POST) call to a servlet which streams back a Microsoft Word document. I arrives back safely, but I don't know how to spawn a new window (window.open) and populate it with the contents of that Word document. Any thoughts?
 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,
What about opening a new window first and using javascript in the new window to do a form submit to get the server side to stream your application data?

My 2 cents.

- Susanta
 
David Bates
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. I had thought of that and it's what I'll do if all else fails.

I just think there has to be a way of passing back the binary data to the window.
 
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the parent window you can open a new window and obtain the reference to document of the new window


This should work
[ September 26, 2006: Message edited by: Purushothaman Thambu ]
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should just call the serverside page directly in the window.open or an in iframe. Do not do an Ajax call since JavaScript can not handle binary data.

Eric
 
David Bates
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You should just call the serverside page directly in the window.open or an in iframe. Do not do an Ajax call since JavaScript can not handle binary data.



Agreed, doing some more digging it does appear AJAX just isn't fitted for fetching binary data.

However, how can you specify a POST method using the techniques you suggest?
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://forum.java.sun.com/thread.jspa?threadID=548763&messageID=4368470

Eric
 
David Bates
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eric, was there something different I was meant to see in that link? It looks like the "hidden form submitted using Javascript" technique discussed earlier:

 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It showed you how to post the form to another window. Isn't that what you were asking?

Eric
 
David Bates
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure, but I can't see it suggesting a technique that hasn't been discussed above, that's all.
 
It's never done THAT before. Explain it to me tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic