This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes JSTL (c:set) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "JSTL (c:set)" Watch "JSTL (c:set)" New topic
Author

JSTL (c:set)

Steven Colley
Ranch Hand

Joined: Feb 18, 2005
Posts: 290
Hi,

I got this question:

Which of the following are invalid uses of the <c:set> action? (Choose three.)

1- <c:set scope="page">value</c:set>
2- <c:set value="value" var="${myVar}" />
3- <c:set var="myVar" scope="${scope}">value</c:set>
4- <c:set target="${myTarget}" property="myProp">propValue</c:set>

5- <c:set value="${myVal}" target="myTarget" property="${myProp}" />

With the following answer for the 5th option:

"5 is also valid syntax. Value, target, and property are set as attributes, with the values for value and property coming from EL expressions, which is legal."

i guess it�s wrong.

1- "property" attribute does NOT take a "request-time expresion".
2- IT�s MANDATORY for "target" attribute to be a request-time expression.

am i wrong?

Tks;


SCJP | SCWCD | SCBCD | SCWSD 5 | SCEA (I) 1.4 | SCEA 5 | IBM SOA 669
Connie Ky Leung
Ranch Hand

Joined: Jan 29, 2006
Posts: 42
Originally posted by Felipe Pittella:
Hi,

I got this question:

Which of the following are invalid uses of the <c:set> action? (Choose three.)

1- <c:set scope="page">value</c:set>
2- <c:set value="value" var="${myVar}" />
3- <c:set var="myVar" scope="${scope}">value</c:set>
4- <c:set target="${myTarget}" property="myProp">propValue</c:set>

5- <c:set value="${myVal}" target="myTarget" property="${myProp}" />

With the following answer for the 5th option:

"5 is also valid syntax. Value, target, and property are set as attributes, with the values for value and property coming from EL expressions, which is legal."

i guess it�s wrong.

1- "property" attribute does NOT take a "request-time expresion".
2- IT�s MANDATORY for "target" attribute to be a request-time expression.

am i wrong?

Tks;



After going over JSTL specification and HFSJ regarding <c:set>, I believe the answers to this question are 1,2, 3 and 5.

5 is invalid because the value of target is a string literal. Its value is EL expression, <%= %> or <jsp:attribute> that evaluats to a Map object or a Java bean.

Please correct me if I am wrong.


SCJP 1.4 - 91%, SCWCD - 97%, SCJP 5.0 - 83%, SCJP 6.0, OCEJWCD - 80%
Steven Colley
Ranch Hand

Joined: Feb 18, 2005
Posts: 290
HI Connie,

I guess that the only one correct is the option 4 in this case.

1 - if there is "scope" attribute, so is mandatory to have "var" or "target" attribute as well.
Error rg.apache.jasper.JasperException: Validation error messages from TagLibraryValidator for : Illegal scope attribute without var in "core:set" tag.

2 - wrong, "var" attribute cannot take request-time expressions.

3 - wrong, "scope" attribute cannot take request-time expressions as well.
Error rg.apache.jasper.JasperException:Validation error messages from TagLibraryValidator for :Invalid "scope" attribute in "core:set" tag.

4- OK

5- Error , target must have a request-time expression.


Tks Connie
 
 
subject: JSTL (c:set)
 
Similar Threads
target attribute of c:set
c:remove does not remove from all scopes
Regarding JSTL1.1-JSP 2.0-TLD
Headfirst Servlets and Jsp <c:set> pg.457
how to use scope in target version of c:set