aspose file tools*
The moose likes JSP and the fly likes Collection on jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Collection on jsp" Watch "Collection on jsp" New topic
Author

Collection on jsp

fahad siddiqui
Ranch Hand

Joined: Jun 14, 2006
Posts: 85
I get an arraylist from the action on the jsp to display.
now i again want to set the arraylist into action and then submit the page, so that i can again fetch the same arraylist from the request in the action class.

What are the possibilities?

Please advise.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Put the arraylist into the session.


[My Blog]
All roads lead to JavaRanch
fahad siddiqui
Ranch Hand

Joined: Jun 14, 2006
Posts: 85
I want to accomplish this without the use of session.
Ne ideas?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61229
    
  66

"Ne" is not a word. Please use real words when posting.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

This sucks, but you could put the values into hidden parameters.
But you have to separate values with something, like commas, which can be troublesome if some of the values already hold the separator.

<input type="hidden" name="myarray" value="one,two,three"/>
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by fahad siddiqui:
I want to accomplish this without the use of session.
Any ideas?


Why?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Makarandp Parab
Greenhorn

Joined: Sep 26, 2006
Posts: 6
What don't you set the Arraylist object in the Request object. Like request.setAttribute("data", arrobject).

Let me know if it works for you.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Makarandp Parab:
What don't you set the Arraylist object in the Request object. Like request.setAttribute("data", arrobject).

Let me know if it works for you.


The request object is only good for the duration of one 'request'.
The original poster indicated that he wants to be able to retrieve the data after submitting the current page.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61229
    
  66

Originally posted by Makarandp Parab:

Let me know if it works for you.


I can answer that. It won't. Please don't waste people's time suggesting things that you don't know will work or not.
Prabhu Venkatachalam
Ranch Hand

Joined: Nov 16, 2005
Posts: 502


I get an arraylist from the action on the jsp to display.
now i again want to set the arraylist into action and then submit the page, so that i can again fetch the same arraylist from the request in the action class.

What are the possibilities?


You want have an object(ArrayList) along mutiple request. for a particular client?

Possibilities:

1. HttpSession - If it is for particular client.
2. ServletContext - If it for whole application.
3. hidden variable - You can have a hidden variable which will values which arraylist is having and pass it on every request to the action class.In Action class recreate arraylist with this values. but this ugly way of doing.
4. Using Database.

Better to use session or context.


Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />prabhu.venkatachalam@gmail.com
 
jQuery in Action, 2nd edition
 
subject: Collection on jsp