• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Passing ArrayList from JSP to Servlet

 
Ranch Hand
Posts: 129
1
Oracle Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>.
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 129
1
Oracle Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 129
1
Oracle Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 wasn't selected to go to mars. This tiny ad got in ahead of me:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic