Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

a JSTL question in Whizlabs Exam Simulator

 
Ping Li
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Here is my question found in Whizlabs Exam Simulator:

Which of the following JSTL fragment will not delete the "empName" attribute from "session" scope? Select one choice.
a. <c:remove name="empName"/>
b. <c:set var="empName" scope="session" value=""/>
c. <c:remove scope="session" name="empName"/>
d. both a and b
e. None of the above

I think the answer is a and c. Because <c:set> syntax is
<c:remove var="varName" [scope="{page|request|session|application}]/>
not <c:remove name="..." ..../>


But when I checked answer, it shows e. Can anybody help me figure it out? Thanks.
 
Patrick Williams
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question reads which one will NOT remove enpName from the session scope. A, B, and C will all remove empName.
 
peter john greaves
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi patrick

yeah : i misread the q (didnt see the "not"). but surely

a. <c:remove name="empName"/>

default is page not session scope and "name" should be "var". so a wont remove.


b. <c:set var="empName" scope="session" value=""/>

setting to "" doesnt remove the attribute, does it?


c. <c:remove scope="session" name="empName"/>

invalid : should be var="empName"?

d. both a and b

neither will do it so both wont

e. None of the above

meaning "none of the above will not remove" so that's "all of the above will remove"? odd. but i can't agree with e. either.


my JSTL newbie mind needs enlightenment,


peter
 
Patrick Williams
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't catch the the var/name error. I agree! Good Catch! If it were var instead of name, they would all remove the empName attribute. A null value on c:set will remove the empName attribute. That information can be found on pg 25 of the JSTL spec (sec 4.3).
 
Ping Li
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all for replying my question. I passed SCWCD this past Saturday at 84%. From my experience HFSJ is enough for passing the exam. I also did some mock exams from whizlabs simulator (My scores on whizlabs are very close the the real exam).

Thanks,
 
fred rosenberger
lowercase baba
Bartender
Posts: 12266
36
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"java_masker"

I don't know why nobody mentioned this before, but your display name does not meet our naming policy. Please read it, follow the link at the bottom, and change your name to something appropriate.

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