Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

passing back data multiple times from a servlet to JSP

 
venkata vinay bysani
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64632
86
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
Author and ninkuma
Marshal
Pie
Posts: 64632
86
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic