views:

208

answers:

1

I've got some EL code inside of a JSP tag. The line starts as follows:

<c:if test="${pageContext.request.serverName eq \'localhost\'}">

Eclipse throws up an error on this, saying:

Unable to analyze EL expression due to lexical analysis error

I'm unsure what this even means. Is this an eclipse bug? Am I mixing EL and the JSTL tags incorrectly?

+1  A: 

Just do it without backslash:

${pageContext.request.serverName eq 'localhost'}

A JSP with that code:

${pageContext.request.serverName eq 'localhost'}
<c:if test="${pageContext.request.serverName eq 'localhost'}">faith</c:if>

renders "true faith" for me. What does "${pageContext.request.serverName}" show?

Sinuhe
Now I get 'Type mismatch: cannot convert from boolean to String'. I'll test if it actually works without the backslash.
wds
I edited my answer a little.
Sinuhe
It does work, it's just odd that the eclipse parser gets confused. Perhaps a bug?
wds