This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of Machine Learning with TensorFlow and have Chris A. Mattmann on-line!
See this thread for details.
Win a copy of Machine Learning with TensorFlow this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

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: 67504
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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: 67504
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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: 67504
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic