wood burning stoves*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Quoting in EL" Watch "Quoting in EL" New topic
Author

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%>' />
${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 ]

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

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
quotes.
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
shanthi
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
Chittaranjan


Thanks,<br />Chittaranjan<br />SCJP 5.0,SCWCD1.4,SCBCD 5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Quoting in EL
 
Similar Threads
target attribute of c:set
Request Parameters in EL
JSTL (c:set)
Dynamic string in jsp
[JSTL] how can I convert values (string to int) in JSTL