This week's book giveaway is in the NodeJS forum.
We're giving away four copies of Serverless Applications with Node.js and have Slobodan Stojanovic & Aleksandar Simovic on-line!
See this thread for details.
Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

Downloading a file: works with IE but not with Firefox  RSS feed

 
Ranch Hand
Posts: 560
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
the following servlet works if we want to download a file through Internet Explorer 11  (and Edge) :



imageMimeType equals application/octet-stream

However it does not work with Firefox Quantum.

Any idea what could be missing ?

Thanks for helping.

 
Bartender
Posts: 20572
121
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Any idea what could be missing ?



No. We don't know what "does not work" means.

What sort of response does the client get? Are there entries made in the server log files?
 
Rancher
Posts: 3986
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, what image is it?
JPEG, GIF, TIFF, something else?
 
Saloon Keeper
Posts: 5334
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, the MIME type should reflect the image type - application/octet-stream  is not correct for images.
 
Celinio Fernandes
Ranch Hand
Posts: 560
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is a CSV file.
It is legacy code.
It is a bug and I am trying to fix it.
 
Dave Tolls
Rancher
Posts: 3986
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, for some reason I thought this was dealing with images...

Anyway, as Tim asked, what exactly is the error?
What happens on the Firefox browser?
 
Celinio Fernandes
Ranch Hand
Posts: 560
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"It does not work"  in that case means :
blank screen, nothing in the logs server-side and client-side (Javascript)

Yeap, there is some JavaScript involved apparently. I just found out.
 
Dave Tolls
Rancher
Posts: 3986
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about the network traffic?
F12 and look at the network tab.
See what the response is, and compare between IE and Firefox.

If Firefox is getting the response and not displaying it, then look at the Javascript.
If it's not getting the right response then debug the server code.
 
Tim Holloway
Bartender
Posts: 20572
121
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Normally, the first thing you should do when you get a blank screen back is use the brower's "View Page Source" option to see how blank it really is. Although in some cases, a blank screen might be seen when a file download dialog is presented. I don't know of any case where it's proper to get a blank screen for a file download and not get the dialog, though, even though for large files there might be a long delay before the dialog pops up.

If page source is blank and no dialog appears, then most likely one of 2 things happened:

1. Your server code simply didn't return any page content.

2. Your server code threw an Exception and you ate the exception it without logging the exception first.  
 
Celinio Fernandes
Ranch Hand
Posts: 560
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone for your help.
Well, I should have mentioned the following :
1) the application is based on Spring Web flow so there is a form action method which is called when the user clicks on the CSV button
That method stores the file in the flow scope :



2) there is a servlet which is called and which sends the file to the client (browser). It is the code that I already mentioned :


So it is working on IE 11/ Edge but not on Firefox.

What kind of works is if i add the the following code inside the form action method :



But of course i get the following error when Spring Web flow tries to render the view (JSP) since the response was already sent :




 
Dave Tolls
Rancher
Posts: 3986
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You still haven't told us what actually happens.
What calls are made when the button is clicked, and what responses happen, and are they different on IE and Firefox?

Since it's the browser (apparently) then that (it seems to me) is where to look for the issue.
 
Tim Holloway
Bartender
Posts: 20572
121
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've got 2 options there.

One, don't dispatch to a JSP View. After all, the REAL "View" for this request is the CSV itself. HTTP cannot return more than one View for a single Request.

The other option is good in cases like CSV's, YAML or JSON, since those are all text formats. Simply make the JSP be a template and populate it from the beans that the Controller (hopefully!) created with the data values in them.
 
Celinio Fernandes
Ranch Hand
Posts: 560
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to close this thread, I am letting you know that I fixed it.
I used a custom view which extends org.springframework.web.servlet.view.AbstractView.
It has a method streamBinaryDataFromArray which transfers a file to the HTTP client, from an array of bytes.

It now works on both browsers (IE and Firefox). Why the previous way of doing it was not working on Firefox remains a mystery though...

Thanks again for helping.
Staff note (Bear Bibeault):

As a policy we don not remove posts after they have been resolved. Rather use the "mark as resolved" button (looks like a check mark and is under the "Post Reply" button) to mark that a topic has been resolved.

 
He was giving me directions and I was powerless to resist. I cannot resist this tiny ad:
global solutions you can do at home or in your backyard
https://www.kickstarter.com/projects/paulwheaton/better-world-boo
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!