Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getParameter,getAttribute

 
Bharadwaj Adepu
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone please explain in detail what is the Difference between getParameter() and getAttribute().
 
Ankur Bohra
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getAttribute() returns an object so when ever we use a getAttribute() we have to cast the return type that is we have to convert it to the required type like string or int.getParameter always returns a string.

one more difference is where this 2 methods are used...getAttribute is used to get the values from the session and getParameter is used to get the values from the form.(html or a jsp file)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic