• 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

passing back data multiple times from a servlet to JSP

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am designing a search functionality with the below flow:
1) User enters search criteria and clicks on search
2) Once the user clicks on search it will come to server componenet(Servlet) where the search operation is done
3) Results will be returned to users

In the above case the data size which should be returned is huge and it takes lot of time to get all the results. So sending all the data at a time is not an option as it will affect the performance.
I am planning to send the data multiple times by querying small chunks of data and sending them, so that user can see the results which are returned and others will be refreshed while they are seeing the displayed data.

I need to do in struts2 but for this multiple return i am ok to go with a servlet as well. Is there any way to build it in struts2 or through a servlet in an efficient way. If sending the data in small chunks is a good way then what are the efficient ways to achieve that.
 
Sheriff
Posts: 67399
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're thinking about it wrongly.

You don't want to try and "push" chunks to the page. Rather, you want the page to use Ajax to "pull" the chunks when it wants them.

That way you can also control when the "pulls" happen: when the user scrolls near the bottom of the already-fetched data, for example.
 
venkata vinay bysani
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the quick response Bear Bibeault. I was thinking to avoid Ajax, if what i am thinking is wrong and going with Ajax is the correct way then i will go with that.
I will check if there is a way i can use ajax with struts2, other wise I will go with a servlet for this.
 
Bear Bibeault
Sheriff
Posts: 67399
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're not going to be able to do this with "just a servlet". A servlet, or any other pure server side resource, can send the response all at once.
 
venkata vinay bysani
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear Bibeault, could you please let me know what should be used for this purpose and what will be the good approach for achieving this, thanks.
 
Not so fast naughty spawn! I want you to know about
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic