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

Difference betweenn c:set and jsp:useBean

 
Vassili Vladimir
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have this basic question regarding the differnce between c:set and jsp:useBean.

Is the following right ?

If I don't specify the scope, the jsp:useBean takes page as the default scope (looks in the page scope only), but,
c:set starts looking for the attribute starting from the page scope ?

Is that right ?

Please correct me if I'm wrong ...

Thanks in advance ...
 
khushhal yadav
Ranch Hand
Posts: 242
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vassili,

See the basic difference between c:set and jsp:useBean is:
c:set is a JSTL tag
while jsp:useBean is a JSP action.

Second thing, you can use jsp:useBean either to retrieve a bean or create a bean object.
While c:set is used to set the property of an already existing bean not to create a bean or get a bean. c:set works somewhat similar to jsp:setProperty action for java beans.

And third thing,
there is no scope attribute for c:set(when you are using it with target attribute) JSTL tag as it is there for jsp:useBean JSP action.
And if you provide the value of target attribute as an EL expression, searching is from most restrictive scope to least restrictive scope.

Regards,
Khushhal
 
Satyajeet Kadam
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q1) I want know when to use <c:set target>?
Q2)Please let me know things that we can do with bean in parallel with <c:set target> with code?
Q3) <c:set target> helps to add an entry in map isone advantage as to beans? Am i correct?
Q4) Please give simple code that helps me to undertand c:set target in parallel with bean actions?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic