How do I detect if the browser is desktop or mobile? I want to use Java but not WURFL

user717236 picture user717236 · Apr 26, 2012 · Viewed 8k times · Source

I need a solution which will allow me to detect if the browser is mobile (i.e. iPhone, Android phone), desktop, or tablet (i.e. iPad, Nook). Based on the detection, it'll redirect to the appropriate site.

I could use WURFL but this is for a private company, and they are cheap and will not pay for the commercial license. I don't mind making the WURFL code itself public; but the class will be manipulated in a JSP page. If I only am required to make the class that uses the WURFL API code public, and not the surrounding JSP code, perhaps I can use it. That's the question: Behind a commercial entity, what is considered public information, with respect to the WURFL API? Do I have to make my JSP page open-source, too?

If I can't use WURFL, without paying for a commercial license, is there another bundled solution for Java or even JavaScript?

Thank you very much.

Answer

Asif picture Asif · Apr 26, 2012

You should look upon sebarmeli/JS-Redirection-Mobile-Site, it is based on javascript, both free and open source with ease of use and robustness.