• 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

alternate way for setHeader

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
to download a file from my application, i am using setContentType and setHeader....as

response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-dissposition","attachment;filename=filename.xls");


can anyone help me with other ways of doing this because the above method requires the user to make browser settings and i see it doesn't work for some browsers.

Thanks in advance
 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
would you be able to attempt to determine the browser type the user is using
(such as somewhere else, where you do have a request object, doing a request.getHeader("user-agent"), using the heuristics for what values are found, and storing the result into the user's session.

then with that browser-specific knowledge available to the download spot, it can do if ( browser type == ...) and provide the specific use and values of the content type response headers to make the browser happy.
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rather than make browser-specific code, which will be difficult at best, and nearly impossible to maintain with versions of browsers coming out all the time with different behaviors, I think it would be important to know what problems the headers are actually giving? What is the desired capability? What is happening?

The headers you posted are the standard ones (except with a spelling mistake for Content-Disposition) and should work as per client-expectations (they are, after all the ones that set up their browser, and should be the ones that define how their browsers work). Fooling with client-expectations can be annoying to the client and fragile to your code.
 
reply
    Bookmark Topic Watch Topic
  • New Topic