• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Quoting in EL

 
Yati Tan
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a problem in "QUOTING CONVENTIONS" in Jsp. Iam going through the specifications. but still puzzled. Pls help me why following are illegal :

1)<c:set var="yt" value= '<%=hi%>' />
${yt}


And following are Legal :

1) <c:set var="yt" value= '<%="hi"%>' />
${yt}


2) <c:set var="try" value='<%=\"hi\"%>' />
${try}



Pls help !!
[ February 18, 2006: Message edited by: Yati Tandon ]
 
Ranjani Theyagarajan
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you don't specify the quote... it will interpret hi as an attribute... but we dont an attribute hi it only a String so we need to specify it within
quotes.
 
shanthisri mocherla
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
Why can't we use JSP expression to print the value of yt using this statement??(instead of EL expression).


I think that the variable set using <c:set> tag can be printed out using only EL expression.
<%= yt%>.I'm getting this error.

cannot resolve symbol
symbol : variable yt
location: class org.apache.jsp.another_jsp
out.print( yt);
^
1 error
thanks in advance
shanthi
 
P Chittaranjan
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi shanthisri,

<%=yt %> will look for a variable inside service method.

<c:set > will not put the variable in service method.

That means you are printing a local variable "yt", which is not there in service method.



<c:set > creates a page-scoped variable.
You can access it through pageContext implicit object.


Thanks
Chittaranjan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic