aspose file tools*
The moose likes Servlets and the fly likes Values of HttpSession object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Values of HttpSession object" Watch "Values of HttpSession object" New topic
Author

Values of HttpSession object

PradeepPillai Pradeep
Ranch Hand

Joined: Nov 15, 2005
Posts: 184
How can I get the values of an HttpSession Object. From the API, I know that I can use getValue method.
But how would I know what are the values I can get?
Any help greately appreciated.
Thanks in advance,
Pradeep
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

getValue is deprecated and replaced with getAttribute.

With setAttribute, you can retrieve whatever values you put into it using setAttribute.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jaime M. Tovar
Ranch Hand

Joined: Mar 28, 2005
Posts: 133
If you are looking for the names you can do a getAttributeNames() this will return an enumeration with all the names of attributes in session then you can iterate the enumeration to get each and then ask for its value with getAttribute(name)


She will remember your heart when men are fairy tales in books written by rabbits.<br /> As long as there is duct tape... there is also hope.
PradeepPillai Pradeep
Ranch Hand

Joined: Nov 15, 2005
Posts: 184
Thank you. Both of the replies are helpful. Hi Bear, so in order to get values or attributes do I have to set attributes first?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

Objects that you set into the session using setAttribute are known as scoped variables. You can also set such variables into page (if a JSP), request, and application scopes.

For the session, I do not believe that there are any built-in values. So if you don't put anything there, there's nothing to retrieve.

The container will sometimes populate the other scopes with some built-in values (for example, putting error information into request scoped variables when an error is detected).
PradeepPillai Pradeep
Ranch Hand

Joined: Nov 15, 2005
Posts: 184
Thank you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Values of HttpSession object