File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Quoting in EL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Quoting in EL" Watch "Quoting in EL" New topic

Quoting in EL

Yati Tan
Ranch Hand

Joined: May 28, 2005
Posts: 56
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%>' />

And following are Legal :

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

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

Pls help !!
[ February 18, 2006: Message edited by: Yati Tandon ]

SCJP 1.4<br />SCJA 1.0<br />SCWCD 1.4
Ranjani Theyagarajan

Joined: Feb 08, 2006
Posts: 19
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
shanthisri mocherla
Ranch Hand

Joined: Sep 05, 2005
Posts: 119
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
P Chittaranjan
Ranch Hand

Joined: Feb 09, 2006
Posts: 47
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,<br />Chittaranjan<br />SCJP 5.0,SCWCD1.4,SCBCD 5
I agree. Here's the link:
subject: Quoting in EL
It's not a secret anymore!