Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Passing ArrayList from JSP to Servlet

 
Ranch Hand
Posts: 127
1
Oracle Opera Java
  • 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 . ...
 
Author and all-around good cowpoke
Posts: 13078
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
 
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>.
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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: 127
1
Oracle Opera Java
  • 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: 127
1
Oracle Opera Java
  • 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..
 
I'm a lumberjack and I'm okay, I sleep all night and work all day. Lumberjack ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic