• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

HFSJ pg 445 c:set

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gentlemen!

In order to check the <c:set var...> I wrote like as follows,

Servlet



JSP



I do believe that I should get:

"The Name is: Thiri"

But I get:

"The name is: Cowboy" !!!

Why?

Thank You!
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

First, you are setting a session attribute called userLevel in your servlet. Then, you are forwarding to a JSP. In this JSP, you are overwriting the session attribute userLevel, by setting its value to "Cowboy". What did you expect it to be "Thiri" if you overwrite it with "Cowboy" ?
 
Mukunthan Shanmuganathan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Christophe Verre!

Thank you, But, the same result comes when I use with body! i.e.

servlet as the same but the JSP as follows



Why?

Dose it mean that <c:set> with body won't act as conditional! as like <jsp:setProperty> ?


Thank you!

:roll:
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both syntax above should give the same result. What do you mean by "the same result comes when I use with body!" ?
 
Mukunthan Shanmuganathan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Christophe Verre!

What I meant by saying "same result" was,

The session scope attribute "userLevel" set by the <c:set...> in the JSP was displayed!

Where as the HFSJ says that "If there's NOT a session-scoped attribute named "userLevel", this tag creates one ..."

If so, If there IS a session-scoped attribute named "userLevel" !

What will happen?

Won't skip the <c:set> like we studied with <jsp:setProperty> ?

:roll:

Thank you.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

What will happen?


It will overwrite the previous value. There is no notion of "do it or not" with the c:set tag.
 
Mukunthan Shanmuganathan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Christophe Verre!



Thank You!

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic