This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of TensorFlow 2.0 in Action and have Thushan Ganegedara on-line!
See this thread for details.
Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Parameter versus attributes

Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CAn anyone please explain me the exact difference between parameter and attributes. Is it only "init" and "context" parameters come under parameter.

ex in jsp we have say,
<input type="text" name="n1"/>

then the servlet will extract it as

String x=request.getParameter("n1");

i guess above is correct?. But i want to know where to use parameter or an attribute
Ranch Hand
Posts: 336
Firefox Browser Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will try to explain, sorry my english.

The concept or the theory, is almost equals. (for some situations)

Parameters, are for a configurations of something, I mean, think about on certain behavior, that mean, that you can use parameters for a data base behavior, maybe you configure a parameter, for a a data base in particular, but maybe, another day you can configure that parameter for another database... i dont know if you see the point.

The attributes are most for sharing information on the application, for example, for share information, maybe you want share the name of the user logged, to another component (jsp/servlet), you can give me?

That is my point of view.
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe be you are mixing with initparamters and parameters (request parameters)
Both of them are String.
Init Parameters are of 2 types
Context Init Paramters:
Servlet Init Parameters: Both uses the method getInitParameter(String name)
Normal paramters example form paramters : Accessor method is getParameter(String)

Attributes are objects and can be put into session,request and context

methods are
setAttribute(String name,Object attr);
Object getAttribute(String name);

Thanks and Regards
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to summarise what has been said above, for the purposes of SCWCD:

parameter = a read-only String property (set by client in request, or in app. configuration, e.g. in the DD)

attribute = an Object stored in a scope (by the application, or possibly implicitly by the container)

The method names mostly reflect this convention.
Maan Suraj
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the info
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basic Difference which has already mentioned in this trail..
- Parameters are either of String or String[] type. Mostly it is not set by the Developer.
- Attribute is of Object type. You always need to cast it before usage. It is always set and used by Developer.
Parameters are catagorized in 2 forms

1. Parameters
1a. Request Parameters - query String (Get) / request body (Post)
1b. include/forward request using jsp aram - Code**
** this is the only place, from where parameters can be set / added by

2. Init Parameters
2a. Servlet Init Parameters - DD
2b. Context Parameters - DD

Attributes can be set and retrieved only from the Code. So attributes are always controlled by Developer. ============================================================================
You can also refer to Page 186 of HFJS 2nd Edition.

Atul Samnerkar
[ September 28, 2008: Message edited by: Atul Samnerkar ]
if you think brussel sprouts are yummy, you should try any other food. And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic