• 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

Are getParameter and getAttribute interchangeable?

 
Ranch Hand
Posts: 67
Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"can we use getParameter instead of getAttribute in servlet/jsp ???"
 
Ranch Hand
Posts: 254
1
MySQL Database Java Ubuntu
  • Likes 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your question is a bit vague.

Both of these methods have different purposes. If you want to submit a form or send a GET request to the server, you will always need a 'getParameter()' invoked on a request object to obtain form control values.

When you desire to use a value across subsequent page/many pages in an application use 'getAttribute()' and 'setAttribute()' method. For instance if you want to forward a message to a JSP from a servlet you place that message in the request scoped variable using setAttribute().

 
mohammad shadab
Ranch Hand
Posts: 67
Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ahsan Bagwan wrote:Your question is a bit vague.

Both of these methods have different purposes. If you want to submit a form or send a GET request to the server, you will always need a 'getParameter()' invoked on a request object to obtain form control values.

When you desire to use a value across subsequent page/many pages in an application use 'getAttribute()' and 'setAttribute()' method. For instance if you want to forward a message to a JSP from a servlet you place that message in the request scoped variable using setAttribute().


as you said "If you want to submit a form or send a GET request to the server, you will always need a 'getParameter()" .is there any thing different for POST request???
 
Ahsan Bagwan
Ranch Hand
Posts: 254
1
MySQL Database Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. I indeed meant POST when I referred to form submission (in the context that you want to change server state (like inserting employee record in db)).
 
mohammad shadab
Ranch Hand
Posts: 67
Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ahsan Bagwan wrote:No. I indeed meant POST when I referred to form submission (in the context that you want to change server state (like inserting employee record in db)).

okay thank you ahsan bro...
 
Pay attention! Tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic