A very simple solution:
<% String userAgent = request.getHeader("user-agent"); if (userAgent.matches(".*Android.*")) { out.print("You're an Android!"); } else { out.print("You're something else...");
Due to the very short else-statement, this should only be used if you are serving no more than iOS and Android.
source share