wood burning stoves 2.0*
The moose likes Servlets and the fly likes Getting array data from one servlet to another Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Getting array data from one servlet to another" Watch "Getting array data from one servlet to another" New topic
Author

Getting array data from one servlet to another

Padraig Joseph
Greenhorn

Joined: May 07, 2002
Posts: 13
Hello everyone,
I have a servlet in which an array is created and populated.
I need to allow another servlet to access the values of the array (In the first servlet, the array is created & populated and then part of its values are displayed, while the second servlet should display the whole thing).
How should I do this? I tried using a storage class but this doesn't work.
Amir Kamran
Ranch Hand

Joined: Apr 21, 2002
Posts: 48
Hello!
U can put the array in the context or session object according to ur required condition and the scope u want to give to the array.
In second servlet get the array cast it and use, simply like others attributes u use
S Chandra Mohan
Ranch Hand

Joined: Oct 19, 2000
Posts: 75
I think u cant put the array into session
and pick it up in the next screen.
One more way is to declare it as public so that it will be available in consecutive screens.


Have a wonderful day and wish u success<p>S Chandra Mohan<br />sc_mohan_us@yahoo.com
Padraig Joseph
Greenhorn

Joined: May 07, 2002
Posts: 13
That's brilliant, it worked! Thanks a million.
Amir Kamran
Ranch Hand

Joined: Apr 21, 2002
Posts: 48
Originally posted by S Chandra Mohan:
I think u cant put the array into session
and pick it up in the next screen.
One more way is to declare it as public so that it will be available in consecutive screens.

can u please tell me why u cant put the array into the session and pick it bact. i do it and it is working.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
You don't say if the array data is unique to a particular user or if it changes. If the data can be calculated once and does not change per user, then you can use the servlet context. If it changes per user you should use session - thats what session if designed for.
Bill
 
Consider Paul's rocket mass heater.
 
subject: Getting array data from one servlet to another