Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference between a parameter and an attribute?  RSS feed

 
dhriti joshi
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the diff. between
session.getvalue("aa");
and
request.getParameter("aa");
pl.help
dhriti
[ March 03, 2004: Message edited by: Bear Bibeault ]
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of them is getting the object from the session and the other is getting it from the request.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66205
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly dhriti,
JavaRanch is a community of people from all over the world, many of who are not native English speakers. While using abbreviations like "pl" instead of spelling out "please" is convenient when text messaging your friends on a cell phone or in a chat room, it presents an extra challenge to those that are already struggling with English. Additionally, such shortcuts may confound automated translation tools that patrons of the Ranch may be making use of.
I would like to ask for your help in making the content of JavaRanch a little easier to read for everybody that visits here by not using such abbreviations.
thanks,
bear
JSP Forum Bartender
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66205
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Secondly, as to your question.
There is no getvalue method on the session. There is an older getValue method that is deprecated. You should be using getAttribute.
Besides the fact that one is on the session and one on the request (as Gregg rightly pointed out), there is a vast difference between a parameter and an attribute.
A request parameter is the result of a form or query string submission. An attribute (which can appear in multiple scopes, including request and session) is a datum that has been placed there by previously executed program code.
A servlet may, for example, obtain data from a database, store it in a value object, then place the value object as an attribute on the request. The request is then forwarded to a JSP page where it obtains the value object (via the attribute) for display.
[ March 03, 2004: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66205
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S. I modified your topic title to something a little more descriptive than "pl help".
 
Prakash Dwivedi
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also request.getParameter will always return String where as in session we can keep any java object hence session.getAttribute returns Object
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!