Two Laptop Bag*
The moose likes Servlets and the fly likes Difference between Attributes and Parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Difference between Attributes and Parameters" Watch "Difference between Attributes and Parameters" New topic
Author

Difference between Attributes and Parameters

Vasiq Molvizadah
Ranch Hand

Joined: Dec 24, 2009
Posts: 66
I was little bit confused about the difference between an Attribute and Parameters, so I read some posts in this forum and some information from the Head First JSP and Servlet book and here's what I understood...

Attributes are basically used to share some configuration information and they store the data in form of Strings... you can store them in 3 different scopes which are
1. Application / Context scope.
2. Request Scope.
3. Session Scope.

Parameters are basically used to share some information on an application and they store the information in form of Objects....the parameters can be stored in 3 different scopes which are
1. Application / Context scope.
2. Request Scope.
3. Servlet init Scope.

Is there any other difference between attributes and parameters or where you can use them ???

The post from where I got the info about the difference between Attribute and Parameters is http://www.coderanch.com/t/178084/Web-Component-Certification-SCWCD/certification/Parameter-versus-attributes


Human Knowledge Belongs to the World.
- Vasiq Mz
Ninad Kulkarni
Ranch Hand

Joined: Aug 31, 2007
Posts: 787

Hi Vasiq,
I read that post. I agree with Charles.


SCJP 5.0 - JavaRanch FAQ - Java Beginners FAQ - SCJP FAQ - SCJP Mock Tests - Tutorial - JavaSE7 - JavaEE6 -Generics FAQ - JLS - JVM Spec - Java FAQs - Smart Questions
Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

very easy differnece.............

parameter are use to receive the vales from the invoked method...........
like if the message is invoked..
add(int x,int y);
here x and y are receiving valuse when add method is invoked,so they are parameters..........


attributes are used to send actual values when invoking any method...............
like while invoking add(3,4);
here 3 and 4 are actual valuse so they are attributes............
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

You;ve got "attributes" -- more properly called scoped variables -- pretty well. But you are way off base on parameters.

Parameters are the way that information is passed from the client to the server as part of submission. They have nothing to do with being stored in any scope.

They are the result of a form submission or a query string on a URL.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

shanky sohar wrote:very easy differnece.............

This entire post is not correct -- the subject is request parameters in a Servlet environment, not method parameters and arguments.

And shanky, English sentences conclude with a single period, not a series of 10 of them.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between Attributes and Parameters
 
Similar Threads
Difference between attributes and parameters
New forum for Sun Certified Web Component Developer
Sun Certified Web Component Developer
ServletContext
Mock exams for JSP