Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting array data from one servlet to another

 
Padraig Joseph
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Padraig Joseph
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's brilliant, it worked! Thanks a million.
 
Amir Kamran
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic