Meaningless Drivel is fun!*
The moose likes Servlets and the fly likes different between parameters and attributes 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 "different between parameters and attributes" Watch "different between parameters and attributes" New topic
Author

different between parameters and attributes

anarkali perera
Ranch Hand

Joined: Sep 10, 2009
Posts: 237
is the only different between parameters and attributes is attribute can store object but parameter only can store String.
is there any other differences?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60732
    
  65

They really have nothing to do with each other. Parameters are values that are submitted as part of the HTTP request to the servlet, while attributes (also known as "scoped variables") are values created by the servlets and stored in one of the various scopes.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3815

You can use parameters with the request URL(s), but you can store attributes in various objects like ServletRequest, HttpSession, ServletContext and also in PageContext for JSP.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60732
    
  65

Vijitha Kumara wrote:You can use parameters with the request URL(s)

Not quite accurate. You don't really "use" parameters with URLs. But as I stated, servlet parameters are the result of request parameters submitted on an HTTP request. Whether the parameter data is carried on the URL or within the request body depends upon the type of the request.

but you can store attributes in various objects like ServletRequest, HttpSession, ServletContext and also in PageContext for JSP.
Yes, those are the scopes that I mentioned. Page scope is not available from servlets.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: different between parameters and attributes
 
Similar Threads
Regarding servlet init parameter
passing object from JSP to servlet and vise versa
difference between getParameter() and getAttribute()
Difference between Attributes and Parameters
Difference between a Parameter and an Attribute