• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Quoting in EL

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic