Get your CodeRanch badge!*
The moose likes JSP and the fly likes Passing HashMap object from one jsp to another Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Passing HashMap object from one jsp to another" Watch "Passing HashMap object from one jsp to another" New topic
Author

Passing HashMap object from one jsp to another

pratapsiva sivakumar
Greenhorn

Joined: Nov 10, 2008
Posts: 18
Sir,
I have created a HashMap object in one jsp page.i want to pass the HashMap Object to another jsp page.How to do it with an example please?
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


Pratap,

If both jsp belong to same request , use JSTL <c:set> to set in "request scope" and forward to the other jsp. If its part of next request , then store it in "session scope".
samuel soundra rajan
Greenhorn

Joined: Sep 25, 2009
Posts: 5
if you want that hashtable to multible pages, then add it to session object

session.setAttribute("hashSesObject",hashTableObj);

second page you can get the object by using.

HashTable hashTableObj = (HashTable)session.getAttribute("hashSesObject")


Samuel.S
(Java Programmer)

Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377

Hey,

you can use the <c:set> tag to set it in session scope as well.
Try to avoid using java scriptlets as shown above inside your JSPs as it can make them quite unreadable.

Sean


I love this place!
Ketan Parikh
Greenhorn

Joined: May 24, 2006
Posts: 6
I think from above posts you must have got your answer.

I want to include one more thing which may be helpful to you. If you are not updating your hashMap on different jsps, it is good idea to set read only hashMap in Session Or Request Object.



Ketan Parikh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing HashMap object from one jsp to another
 
Similar Threads
type casting error
passing object from one jsp to another.
HashMap
Please Help: Putting Vector objects into HashMap
How to pass java object b/w two actions