How do you check the browser's user agent in a JSP page using JSTL, EL?

老子叫甜甜 提交于 2019-11-29 09:13:26
<c:set var="browser" value="${header['User-Agent']}" scope="session"/>
Zoltan
<c:if test="${fn:contains(header['User-Agent'],'MSIE')}"></c:if>

If you are using spring-mobile framework you can use following to check device type

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
    <c:choose> 
        <c:when test="${currentDevice.normal}"><p>"Welcome desktop user"</p> </c:when>
        <c:when test="${currentDevice.mobile}"><p>"Welcome mobile user"</p>  </c:when>
        <c:when test="${currentDevice.tab}"><p>"Welcome tab user"</p> </c:when>
    </c:choose>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!