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

Passing ArrayList from JSP to Servlet

 
karthik Suryanarayanan
Ranch Hand
Posts: 121
Java Opera Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I need to pass Arraylist from a jsp to my Handler class via Servlet . I can't use session since my handler class creates new session everytime . How could i achieve it ...

This requirement is for pagination.. I populate arrayList values in my Data class using a web service call. I return those list back to Jsp and display. But when if my list has more than 10 records it needs to be paginated. . Since i follow a specific mvc , i could not provide any pagination logic there . Is there any way to achieve this . ...
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't use session since my handler class creates new session everytime .


Is this "new session everytime" a requirement or is it that you don't know how to prevent it?

Bill
 
manni ma
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I have understood your requirement clearly, one way is to have data holder class with arraylist as public static variable.
Populate this list with your data from servlet. This variable can be used from handler by using <Data Holder className>.<List name>.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The session is the most appropriate means. If your sessions aren't behaving correctly, that needs to be addressed before anything else.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BUT if you are holding more info in the array list than you are displaying, you are doing it wrong. If you are only going to display 10 records, only fetch the 10 records to be displayed. Fetching a bunch of records that might or might not end up being displayed is a sure case of premature optimization.
 
karthik Suryanarayanan
Ranch Hand
Posts: 121
Java Opera Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William Brogden wrote:
I can't use session since my handler class creates new session everytime .


Is this "new session everytime" a requirement or is it that you don't know how to prevent it?

Bill



I'm working on a product which is already developed and i need to develop a new module . The handler class is already defined in the product and i could not go change that. I should follow the existing MVC defined already. I have to impose my code on top of that. Please guide me ..
 
karthik Suryanarayanan
Ranch Hand
Posts: 121
Java Opera Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
manni ma wrote:If I have understood your requirement clearly, one way is to have data holder class with arraylist as public static variable.
Populate this list with your data from servlet. This variable can be used from handler by using <Data Holder className>.<List name>.



I could have more than 1000 records for this . So i could not go for a static one since it will affect my performance at a very high..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic