Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

passing back data multiple times from a servlet to JSP  RSS feed

 
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: 67261
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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: 67261
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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.
 
If you have a bad day in October, have a slice of banana cream pie. And this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!