Sunday, May 23, 2010

Internet Explorer cannot download

In web development, sometimes it is required to download documents to the client. These documents may not be physically existing on the file system, however they are in other place like DB, that is requiring problematically extract the document then send it to the client.

Jspx provides a common method to write files directly to the client.



public

void
writeFile(byte[] file, String fileName, String mimeType)

This method can be called from any jspx controller.


In some application that is using SSL for HTTPS interface. we noticed that if the client side is IE then we got the following error.




Internet Explorer cannot download Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.


We googled the web for such error and ended with the result that is described here

http://support.microsoft.com/default.aspx?scid=KB;EN-US;q316431&

we had to remove both header (Pragma, Cache-Control)


so we did that in the writeFile method and now it look like this:


public void writeFile(byte[] file, String fileName, String mimeType)
      {
            try
            {
                  this.response.setHeader("Content-disposition", "attachment; filename=" + fileName);
                  this.response.setContentType(mimeType);
                  // [May 23, 2010 4:51:08 PM] [Amr.ElAdawy] [removing the caching control headers
                  // in order to solve the https problem]
                  this.response.setHeader("Pragma", null);
                  this.response.setHeader("Cache-Control", null);
                  OutputStream out = this.response.getOutputStream();
                  out.write(file);
                  out.close();
            }
            catch (IOException e)
            {
                  e.printStackTrace();
            }
            catch (Exception e)
            {
                  logger.error("Excpetion while writing file file ", e);
            }
            this.skip();
      }


which had solved the problem

cheers,







36 comments:

  1. Thanks too much for this piece of info, actually I find it very useful.

    Also, the function writeFile() is very useful too - I've used before.

    ReplyDelete
  2. Wοah! I'm really digging the template/theme of this site. It'ѕ simplе, yet еffеctive.
    А lot οf tіmeѕ it's very difficult to get that "perfect balance" between superb usability and appearance. I must say you have done a excellent job with this. Also, the blog loads super quick for me on Safari. Exceptional Blog!

    Also visit my web-site - http://Pikavippis.net
    Here is my site : pikavippi

    ReplyDelete
  3. Hеllo, іts nicе pіece οf ωгiting on the
    topic οf mediа prіnt, wе аll be familiar
    with mеdia is a great souгce of facts.
    my web site > buy followers on instagram

    ReplyDelete
  4. What's up Dear, are you truly visiting this site regularly, if so afterward you will definitely get nice know-how.

    Also visit my blog ... vapornine
    Also visit my webpage vapornine

    ReplyDelete
  5. Heу just wаnted to givе yοu а quіck
    heаdѕ up. The text in yοur content
    ѕeem to be running оff the ѕcreen in Fiгefox.
    I'm not sure if this is a format issue or something to do with web browser compatibility but I thought I'd poѕt to let you knοw.
    Thе ԁeѕіgn looκ great though!
    Hoρе уou get the issue solved sоon.
    Тhanκѕ

    mу ωeb-sіte :: Fkf
    My page: meq

    ReplyDelete
  6. It's really very complex in this full of activity life to listen news on TV, thus I only use web for that purpose, and take the hottest information.

    Also visit my website - gdh
    Also visit my blog post - uzn

    ReplyDelete
  7. Greetings! I've been following your site for a while now and finally got the courage to go ahead and give you a shout out from New Caney Texas! Just wanted to mention keep up the great job!

    Feel free to surf to my webpage - zgj

    ReplyDelete
  8. Greetings! Very helpful advice within this post!
    It's the little changes that make the most significant changes. Many thanks for sharing!

    Take a look at my blog; tfb

    ReplyDelete
  9. I'd like to thank you for the efforts you've put
    in writing this site. I really hope to view the same high-grade blog posts by you in
    the future as well. In truth, your creative writing abilities has encouraged me to
    get my very own site now ;)

    Look into my weblog :: use Photoshop to place your photo and 60 characters of text on a huge billboard in the middle of a busy city and send you Big Jpg
    My website - your-task.com

    ReplyDelete
  10. Fine way of telling, and pleasant post to take data on the
    topic of my presentation focus, which i am going to present in
    university.

    my blog - get followers

    ReplyDelete
  11. This is my first time pay a visit at here and i am genuinely pleassant to read
    everthing at single place.

    Have a look at my web-site; ava fx
    my site > ava fx

    ReplyDelete
  12. Thanks for finally writing about > "Internet Explorer cannot download" < Loved it!

    Review my homepage - best-retweet.
    com

    Also see my web page: affiliate marketing on twitter

    ReplyDelete
  13. I read this article fully on the topic of the comparison
    of most up-to-date and previous technologies, it's remarkable article.

    Feel free to visit my webpage :: aaa fx

    ReplyDelete
  14. Hello there! I know this is kinda off topic however
    , I'd figured I'd ask. Would you be interested in trading links or maybe guest writing a blog article or vice-versa?
    My website addresses a lot of the same topics as yours and
    I feel we could greatly benefit from each other.
    If you happen to be interested feel free to shoot me an email.
    I look forward to hearing from you! Wonderful blog by the way!



    Feel free to visit my web-site: xgbook.com

    ReplyDelete
  15. Thanks , I've recently been looking for information about this topic for ages and yours is the best I have found out so far. But, what concerning the conclusion? Are you sure concerning the supply?

    Here is my blog post ... squeeze page

    ReplyDelete
  16. I'm extremely inspired together with your writing abilities as neatly as with the format for your blog. Is this a paid subject or did you customize it yourself? Anyway stay up the excellent quality writing, it's rare to look
    a nice weblog like this one these days..

    My weblog; investment trading

    ReplyDelete
  17. I loved as much as you will receive carried out right
    here. The sketch is tasteful, your authored subject matter stylish.

    nonetheless, you command get bought an nervousness over that
    you wish be delivering the following. unwell unquestionably come
    more formerly again since exactly the same nearly very often inside case you shield this hike.


    my web blog :: landing page template

    ReplyDelete
  18. I visited various web sites but the audio quality for
    audio songs current at this web page is in fact
    marvelous.

    My web-site; get followers

    ReplyDelete
  19. UGG Australia has produced some unique and
    fun types in boots for females - Classic Stripe UGG Boots actually are a perfect illustration of the.
    There are several types for babies, however the very top of
    the favorites list include:. Nevertheless, with super
    delicate ease and convenience, increased desire, and
    winter months season approaching, you are able to still discover some very nice provides.


    my homepage コーチ バッグ

    ReplyDelete
  20. Cheap Burberry Handbags These furnishings can be a good choice.
    ì (IE: sand, chestnut, chocolate, black) UGG boots.
    So you will get that shoes, clothes, even bags for children has become more exquisite than before.


    Here is my web blog; コーチ 長財布

    ReplyDelete
  21. hi!,I like your writing very much! percentage we keep up a correspondence extra about your post on AOL?
    I need a specialist in this house to resolve my problem.
    Maybe that is you! Looking forward to peer you.

    my webpage Best hdtv 2014

    ReplyDelete
  22. Verʏ nice post. I just stumbled upon your wеblog and
    wanted to saу that I've truly enjoyed surfing around your blog posts.
    In any case I'll be sսbscrіbing to your feed and I hօpe you write again soon!

    Alѕo visit my sitе castle clash hack

    ReplyDelete
  23. Hey, I am neԝ tߋ blogging ɑnd internet sites іn geneгal ɑnd was wantingg
    to ƙnow ɦow you got tҺe "www" included іn ƴou domain name?
    ӏ seee your domain namе, "https://www.blogger.com/comment.g?postID=2151192657592288150&blogID=7858118152431838056" has the www and mу wweb
    address loks likе, "http://mydomain.com". Do yyou knolw tɦe Ƅest wɑy I can alter
    tҺis? I'm using Wordpress platform. Thankks fօr yοur time

    Feel free tо visit mʏ homepage :: Hay Day Hack

    ReplyDelete
  24. Thanks for every other wonderful post. The place else may anybody
    get that kind of info in such a perfect method of writing?
    I have a presentation subsequent week, and I am on the look
    for such info.

    Here is my site Hen House Grocery Store Ks

    ReplyDelete
  25. Hello friends, how is all, and what you desire to say concerning this
    article, in my view its in fact awesome designed for me.


    Here is my web site ... elements epic heroes hack

    ReplyDelete
  26. Hi! I simply would like to give you a huge thumbs up for your great information you
    have got here on this post. I am returning to your site for more soon.

    Look at my site ... www

    ReplyDelete
  27. Quality posts is the main to interest the visitors to visit the web page, that's what this website is
    providing.

    Also visit my website; best skin care

    ReplyDelete
  28. Hmm it appears like your site ate my first comment (it was super long) so I
    guess I'll just sum it up what I had written and say, I'm thoroughly enjoying your blog.
    I too am an aspiring blog blogger but I'm still new to the whole thing.
    Do you have any suggestions for rookie blog writers?
    I'd really appreciate it.

    Feel free to visit my web blog ... best thumbnail generator

    ReplyDelete
  29. Please let me know if you're looking for a article author for your site.
    You have some really great posts and I think I would be
    a good asset. If you ever want to take some of the load off, I'd really like to write
    some material for your blog in exchange for a link back to mine.
    Please blast me an e-mail if interested. Thank
    you!

    Also visit my website :: bsn Mass Stack

    ReplyDelete