Meaningless Drivel is fun!*
The moose likes JSP and the fly likes passing object from one jsp to another Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "passing object from one jsp to another" Watch "passing object from one jsp to another" New topic
Author

passing object from one jsp to another

Shivaprasad P Kanaganahallimath
Ranch Hand

Joined: Sep 25, 2006
Posts: 48
Hi i need to pass an arraylist from one jsp to another jsp.
So i thought of using session object, it works fine for the first time.
But if i come back(navigate back)and submit again then the session is retaining old values also.How to get rid of the old values in session
[ April 17, 2008: Message edited by: Bear Bibeault ]

Shiva Prasad P.K.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

session.removeAttribute()


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Shivaprasad P Kanaganahallimath
Ranch Hand

Joined: Sep 25, 2006
Posts: 48
I have tried doing it,but it doesn't seem to work when I revisit the page for third time.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Originally posted by Shivaprasad P Kanaganahallimath:
but it doesn't seem to work when I revisit the page for third time.

This doesn't tell us anything that would be useful in helping you.
Sonal Sharma
Ranch Hand

Joined: May 13, 2006
Posts: 62
try to use request scope if you want to retain this object for just a request
Shivaprasad P Kanaganahallimath
Ranch Hand

Joined: Sep 25, 2006
Posts: 48
I am setting the arrayList a in request object in report.jsp
request.setAttribute("report",a);

once I submit the the form, it will go to report1.jsp
here I am supposed to get the arraylist.But when i try to do request.getAttribute("report") it returns null.
Shivaprasad P Kanaganahallimath
Ranch Hand

Joined: Sep 25, 2006
Posts: 48
thanks to all , issue has been resolved....
vishnu bola
Ranch Hand

Joined: Jun 01, 2009
Posts: 32
Hi Sivaprasad,

Could you please let me know how you resolved the issue? I am also facing the same problem in passign arraylist to another jsp.

It would be useful if you mention how you resolved it.

Thank You
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
Hey Vishnu,

It's nice that you want to help him. But the thread is more than a year old and it's very unlikely that he is still looking for the solution through this thread.
Tauri Valor
Ranch Hand

Joined: Aug 03, 2005
Posts: 166
Have a look at the following piece of code, and try to use it in the first jsp



A Moment's insight is sometimes worth a Life's experience.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Scriptlets in a JSP? It's 2009, not 2002.

Session attributes should either be handled in controllers or using JSTL tags.
Tauri Valor
Ranch Hand

Joined: Aug 03, 2005
Posts: 166
Thanks Bear!

JSTL equivalent:



 
It is sorta covered in the JavaRanch Style Guide.
 
subject: passing object from one jsp to another
 
Similar Threads
Retrieving data in session
database with jsp
need to submit external form from my jsp
refreshing html table
Same user different browser window ? new seesion or old one?