• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFSJ pg 445 c:set

 
Mukunthan Shanmuganathan
Ranch Hand
Posts: 32
  • 0
  • 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!
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • 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
  • 0
  • 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
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • 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
  • 0
  • 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
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Christophe Verre!



Thank You!

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic