title: Java JSP/Servlet: how to automatically serve either a .dmg or a .exe file?
body: <p>What is the correct way to automatically serve either a .dmg or a .exe file depending on the OS/browser the user is using to connect to a Java Webapp?</p>
  
  <p>I'd like to do it server side, without having to use any JavaScript.</p>
  
  <p>For example if, from an OS X machine, I go to: <a href="http://www.absolutepoker.com" rel="nofollow noreferrer">absolute poker</a> and click on <em>"Download &amp; Play"</em> (it is just an example of a website that has the behavior I'm looking for) it serves me a <em>.dmg</em> file that is automatically downloaded by Safari.</p>
  
  <p>I'm looking for a solution that is practical: if it works for 99% of my users I'm happy. I don't care if for some very particular OS/browser combination it doesn't work, as long as "most of the time" Windows users gets served a <em>.exe</em> and OS X users a <em>.dmg</em>.</p>