• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

q on JSTL

 
JayaSiji Gopal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wht is wrong with the following JSP:
<%@taglib uri="http://java.sun.com/jsp/jstl/core prefix="c">
<% Double result = new Double(5);
pageContext.setAttribute("result",result);
%>
<c:if test="${result==5}" var="result" scope="page"> The result is ${result}
</c:if>

1) A classCastException is thrown.
2) A compilation error.
3) result is true.
4) result is 5.

i feel is is 3, but i have a doubt regarding 1. Plz help.
 
Priya Jothi
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it is option 2.

Regards,
Priya.
 
JayaSiji Gopal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi priya,

Y do u feel, it is 2. plz explain.
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The compilation error is because of

<%@taglib uri="http://java.sun.com/jsp/jstl/core prefix="c">

This should be

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

Otherwise it will return true.

thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic