aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes HFSJ pg 445 c:set Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "HFSJ pg 445 c:set" Watch "HFSJ pg 445 c:set" New topic
Author

HFSJ pg 445 c:set

Mukunthan Shanmuganathan
Ranch Hand

Joined: Jul 24, 2007
Posts: 32
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!


Dare to know!
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16


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" ?


[My Blog]
All roads lead to JavaRanch
Mukunthan Shanmuganathan
Ranch Hand

Joined: Jul 24, 2007
Posts: 32
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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

Joined: Jul 24, 2007
Posts: 32
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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

Joined: Jul 24, 2007
Posts: 32
Hi Christophe Verre!



Thank You!

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HFSJ pg 445 c:set
 
Similar Threads
Problem regarding to Cookies with EL, HFSJ pg 386
Servlet problems on Orion
jsp:useBean
how to invoke applet from servlet
InitialContext Lookup returns the same Stateful Session Bean Reference everytime ...