• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

getAttribute vs getParameter

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I sometimes find it confusing to decide between the usage of getAttribute() and getParameter(). What is the major difference between these 2 functions?

Do servlets use both these functions? What about JSP. Does JSP use these 2 functions?


Thanks in advance.
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With getParameter(), you can retrieve only String values.
With getAttribute(), you can retrieve even objects.
 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Navaneetha

YOu can read HFSJ page:186 will give nice comaprision for attribute and Parameter.
Yes you are right for request as
String request.getParameter(String)
Object request.getAttribut(String)

But attribute is far better.If you want to get/set attribute in session and Contect scope there u can set attribute only.

You read attribute and listenr chapter first and then jsp attribut together too.


As personally i had a same problem but after reading together my dought is clear.hope this will help you to clarify your dought.

Thanx
sanjay
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic