This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes passing back data multiple times from a servlet to JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "passing back data multiple times from a servlet to JSP" Watch "passing back data multiple times from a servlet to JSP" New topic
Author

passing back data multiple times from a servlet to JSP

venkata vinay bysani
Greenhorn

Joined: Feb 09, 2010
Posts: 25
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

Joined: Jan 10, 2002
Posts: 60785
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
venkata vinay bysani
Greenhorn

Joined: Feb 09, 2010
Posts: 25
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

Joined: Jan 10, 2002
Posts: 60785
    
  65

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

Joined: Feb 09, 2010
Posts: 25
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: passing back data multiple times from a servlet to JSP
 
Similar Threads
Struts2
migration to Struts2
Struts2/JQuery
struts2 workflow question
Struts2 questions