• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in SCWCD EL mock question

 
agila arvind
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
For the following question , I thought the answer would be 223. But the correct answer is 123.If EL can apply + operator in ${Two+1} to give 3 , why ${One+1} is not evaluated to 2 ?


Question:
What will happen when you attempt to compile and run the following JSP page contents?


<%request.setAttribute("Two","2");
Integer One = new Integer(1);%>
${One + 1}
${Two}
${Two + 1}
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by agila arvind:
<%request.setAttribute("Two","2");
Integer One = new Integer(1);%>
${One + 1}
${Two}
${Two + 1}


hi, to display the One in EL,it needs to bind within scope variable. here Two is in request scope where one in not in any of the scope so it print nothing right?

EL is not designed to mingle with scriptlet

Hope this helps
[ December 14, 2008: Message edited by: seetharaman venkatasamy ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Searching the forum can help too Here is a similar thread.
 
agila arvind
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you ranchers. I got it now.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic