• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SCWCD HFSJ query regarding chapter 5

 
Anant Nimbalkar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am preparing for SCWCD and reffering to HFSJ for preparation..

I am not clear with the difference between attributes and Parameters...
though there is explanantion given there but I find it ensufficient (at least for me as working with servlet for the first time)

While reading the dark side of attributes I got them mixed up with parameters...

Anybody , can give a simple yet distinctive example about attributes and parameters..

Thanks in advance ,
Anant
 
Irina Goble
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A silly one: parameters are Strings only, attributes are Objects.

There are few places where parameters can come from. Context parameters and init-params are defined in web.xml, request parameters come with a client's request or from <jsp aram> standard action.

Parameters and attributes both are key/value pairs, may be that is why it's confusing.
 
Higor Zardo
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very good!!
And what is attribute class?
 
Riya Pant
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As all java objects inherit java.lang.Object class , all can work as the value of attribute. AS you can have an attribute named "members" having an "Arraylist of String" as its value.
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Attribute:
we setting attribute to request with one value with the name for that value if we put the other value with same name then privously placed value is getting replaced with new value.

Parameter:
Where as in parameter, if second paramter is added in request with same name taht exist in request's parameter already.
the we can get all values we have in request with same name by method,
javax.servlet.ServletRequest.getParameterValues(java.lang.String)
(returns array of string & parameter passed is name for which we want value)
 
Deepak Chopra
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Attribute is some that you can add programatically, we have methods like addAttribute, setAttribute to do so.

Parameter is something we can not add. We receive parameter whenever a form is submitted ( in the request) and init/context parameter that comes via web.xml to config/context respectively.

there is not addParameter or setParameter..!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic