0

I am trying to compare value of meta tag returned by sitemesh with a string but its not displaying correct result. Below is code what I am trying. Please Let me know if something wrong.

<c:set var="pageName" scope="request"  ><sitemesh:write property='meta.menu'/></c:set>
<c:if test="${pageName=='Doctorhome'}"> somthing </c:if>

This is not printing if block content. Also I tried to print ${pageName}, it prints Doctorhome.

Kindly let me what problem is there.

Rahul Rox
  • 11
  • 3

3 Answers3

0

Try with the value attribute of c:set tag,

<c:set var="pageName" scope="request" value="${<sitemesh:write property='meta.menu'/>}" />
<c:if test="${pageName == 'Doctorhome'}"> somthing </c:if>
Santhosh
  • 8,181
  • 4
  • 29
  • 56
0

"pageName" is in the request scope, so change this line:

<c:if test="${pageName=='Doctorhome'}"> somthing </c:if>

to

<c:if test="${requestScope.pageName=='Doctorhome'}"> somthing </c:if>

Also check requestScope.pageName for white space when you dump it to a screen, by prepending and appending a character before and after it:

<c:out value="=${requestScope.pageName}="/>

And make sure there are no spaces between the equal signs and the DoctorHome text.

alfreema
  • 1,308
  • 14
  • 26
  • I tried as you suggested. But while printing with it prints ''. but if same i print with ${requestScope.pageName} it prints 'Doctorhome'. I am feeling as sitemesh tag is processing after the operation of C tags. – Rahul Rox Jul 18 '14 at 05:40
  • In sitemesh 2 we had decorator:getproperty tag with that my requirement was working properly. But in sitemesh 3 I am unable to get same funcationality as decorator:getProperty. If anyone have an idea, please let me know. – Rahul Rox Jul 18 '14 at 05:46
0

After doing a lot of R&D I observed sitmesh write tag is getting processed after the EL. So I am using EL itself to check the page value.

Rahul Rox
  • 11
  • 3