views:

846

answers:

2

I need to check the browser's user-agent to see if it is IE6. However I shouldn't use scriptlets (we have a strict no scriptlets policy) to do this.

Currently I use

   <%
   String ua = request.getHeader( "User-Agent" );
   boolean isMSIE = ( ua != null && ua.indexOf( "MSIE" ) != -1 );
   %>

   <% if( isMSIE ){ %>
   <div>
   <% } %>

What is the cleanest way to do this using JSTL, EL, etc and not scriptlets?

+5  A: 
<c:set var="browser" value="${header['User-Agent']}" scope="session"/>
laginimaineb
A: 
<c:if test="${fn:contains(header['User-Agent'],'MSIE')}"></c:if>
Zoltan
<c:if test="${fn:contains(header['User-Agent'],'MSIE')}"></c:if>
Zoltan
Zoltan, you need to add four spaces to the beginning of code so that it's displayed properly.
Welbog