This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
  • 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

what is the attribute in servlet ?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello!!
Iwas bit confused about the scope of attributes while using them.what is the difference between getParameter() and getAttrbibute() in servlet,jsp.
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
getAtribute() fetches a scoped variable placed into the target scope. getParameter() returns the value of a request parameter that was submitted as part of a form or on the query string of the URL.
 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
getParameter is used to read the HTML/JSP field values (text box, radio button etc) and getParameter returns a String.

getAttribute is used get object available in request, session and servletContext. getAttribute returns an Object.

-Lave

Originally posted by vidya vani:
Hello!!
Iwas bit confused about the scope of attributes while using them.what is the difference between getParameter() and getAttrbibute() in servlet,jsp.

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
putting in simple words
use getParameter() when the request /form is submitted to the server where as getAttribute() can be used at page,sesion and application level

-if a variable is set at request level using setAttribute that can be accessed by getAttribute only in the immediate submitted page
-if a variable is set at session level using setAttribute that can be accessed by getAttribute throught the session availability
-if a variable is set at context level using setAttribute that can be accessed by getAttribute through out the application by all the users
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi...
get parameter is used to get the value for one jsp page to other.
But,getAttribute is related to httpsession...

siva
[ January 19, 2008: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by siva prasad java:

But,getAttribute is related to httpsession...


This is not correct. Scoped variables (aka "attributes") can exist in one of four scopes, including the session.
[ January 20, 2008: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"siva prasad java", please check your private messages for an important administrative matter.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by siva prasad java:
get parameter is used to get the value for one jsp page to other.



This isn't entirely accurate either.
The request.getParameter method is used to retrieve form and query string parameters. In other words, parameters are used to pass values from the browser to the server.

By using hidden input fields, you can use parameters to pass values from one JSP or servlet to another but the primary purpose is to gather user input from the client.
 
A teeny tiny vulgar attempt to get you to buy our stuff
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic