• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

c:set question

 
Akhil Maharaj
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

How these 2 following are different ?

(a) <c:set var="x" value="hello" scope="request" />

(b) <% request.setAttribute("x","world"); %>

In both cases I can acess the value with ${x} . When should I use (a) versus (b)

Thanks
Akhil
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They do the same thing. (b) is the old way to set attributes in the request. You usually should avoid using scriptlets in your JSP. Uou can use custom tags and EL instead. (a) is a cleaner way, using custom tags, to set request attributes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic