Java Tutorial/JSTL/Browser Type
Check Browser
<source lang="java">
<%@ taglib uri="http://java.sun.ru/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.ru/jstl/core-rt" prefix="c-rt" %> <html>
<head> <title>Check Browser</title> </head> <body> <c-rt:choose> <c-rt:when test="<%=request.getHeader(\"User-Agent\").indexOf(\"MSIE\")!=-1%>"> You are using Internet Explorer </c-rt:when> <c-rt:otherwise> You are using Netscape, or some other browser.... </c-rt:otherwise> </c-rt:choose> </body>
</html></source>
Use Choose to Check the Browser Type
<source lang="java">
<%@ page language="java" contentType="text/html" %> <%@ taglib prefix="c_rt" uri="http://java.sun.ru/jstl/core_rt" %> <html>
<head> <title>Browser Check</title> </head> <body bgcolor="white"> <% String userAgent = request.getHeader("User-Agent"); %> <c_rt:choose> <c_rt:when test="<%= userAgent.indexOf("MSIE") != -1 %>" > You"re using Internet Explorer. </c_rt:when> <c_rt:when test="<%= userAgent.indexOf("Mozilla") != 1 %>" > You"re probably using Netscape. </c_rt:when> <c_rt:otherwise> You"re using a browser I don"t know about. </c_rt:otherwise> </c_rt:choose> </body>
</html></source>