• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setAttribute(String name, Object value) question

 
john gomez
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Java Ranchers,
I have a dumb question. I am about to take my exam on Monday and was doing some mock tests and have run into several questions regarding setAttribute. I thought the 2nd parameter has to be an object, but I have seen several questions using something like: session.setAttribute("sortby","id"). Isn't the 2nd paramenter here a string and therefore, causes an error???
Any clarification is greatly appreciated.
Thanks.
John
 
Vad Fogel
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John, here's a fragment of my working code:

I believe, using a String as a value of session parameter is perfectly legal since String is an Object.
 
john gomez
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess I've been studying too hard. I need a break. I'm forgetting the basics.
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic