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?
I’d like to do it server side, without having to use any JavaScript.
For example if, from an OS X machine, I go to: absolute poker and click on “Download & Play” (it is just an example of a website that has the behavior I’m looking for) it serves me a .dmg file that is automatically downloaded by Safari.
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 .exe and OS X users a .dmg.
You can extract it from the
User-AgentHTTP headr.Here is a useful resource on how to extract the OS from the User-Agent (it’s PHP, but the data is important).
Update: this provides a much better way to get info from the user agent. (thanks to BalusC for the link)