You should be able to do this:

<c:set var="mozUserAgent"><jsp:expression>((javax.servlet.http.HttpSerletRequest)pageContext.getRequest()).getHeader( "user-agent" ).startsWith( "Mozilla" )</jsp:expression></c:set>

<c:if test="${mozUserAgent}">
  <p>display....</p>
</c:if>
<c:if test="${not mozUserAgent}">
 <p>display something different....</p>
</c:if>

There may be functions in the standard taglib to reduce this to something like:

<c:if test="${not fn:startsWith( header.user-agent, 'Mozilla' )}">
 <p>display....</p>
</c:if>

But I'd have to do more digging into the standard taglib docs than I really want to right now. The first one should work without digging into additional expression language functions.

--David

Nicole Luneburg wrote:
Hi,

I want to do this in my main.jsp page:

<%
   if(request.getHeader("user-agent").startsWith("Mozilla")) {
%>

   display this

<%
} else {
%>

   display this

<%
}
%>

I don't know how to do the request bit ...
Eg is it:

HttpServletRequest request = new HttpServletRequest();
or is it just request.getHeader
or HttpRequest request = new HttpRequest();

Do i need libraries? If so, how does that work in magnolia?
Can I import stuff in magnolia jsp's like in a normal java project?

That's what I'm lost on!

Thanks

----------------------------------------------------------------
for list details see
http://www.magnolia.info/en/magnolia/developer.html
----------------------------------------------------------------


----------------------------------------------------------------
for list details see
http://www.magnolia.info/en/magnolia/developer.html
----------------------------------------------------------------

Reply via email to