aspose file tools *
The moose likes JSP and the fly likes Please suggest how to display partial output from time to time using JSP. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Please suggest how to display partial output from time to time using JSP." Watch "Please suggest how to display partial output from time to time using JSP." New topic
Author

Please suggest how to display partial output from time to time using JSP.

Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 672
I am calling a unix script from Java.Now this script runs for around 10 minutes and returns messages(echo statements). I am able to read these messages as soon as they are sent using a Buffered Reader using Java Class.
The problem is when is doing the same in JSP.Because I want to display the response as soon as a line is displayed and then the next response when next line is read(say after few seconds or minutes). But my JSP page will render only when the entire script runs. How can this be done using JSP.Please advice.

Since this Unix script runs for long time say 10 minutes, I want user to be displayed messages in between indicating the progress so far.(as messages recieved line by line from Unix script). But how to display partial output using JSP and then after period of time display the next output. I do not know AJAX.Is there a way of doing it using JSP?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61794
    
  67

No. You will need to use Ajax.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 672
Ok.but before AJAX technology came, how were developers doing this?
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 672
actually since i dont know ajax, and i have to do this in limited time, i wanted to do this without AJAX.I read on internet that setting partial output as session variable and refeshing the page every second can help.but how exactly to do this i am confused.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61794
    
  67

Yes, before Ajax, one needed to refresh the whole page in order to effect any changes. If you want to use no JavaScript or Ajax, that's the approach you will have to use. You cannot just add parts the to page incrementally -- you need to redo the whole thing.

Not the best user experience, be warned.
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 672
Can you please tell about this approach too? I still have some confusion.

->My JSP page will have buffered Reader reading line by line and displaying this Variable.
--> JSP page will have auto refresh. for every second.

But still the JSP page will be rendered after the entire buffer reader is read? suppose from buffer reader i am reading line by line 1 to 10 at intervals of 1 sec, despite the auto refresh, the JSP page will be rendered at once only after completion of 10 seconds.

Then how to make this approach work.Please suggest if this is possible and i am misssing out something above?
thanks


Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1030
Possibly you might find pushlets applicable in this use case.
Its quite an old article, and I never used them myself, but I think it fits your scenario.

Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 672
thanks all.even Flush serves the purpose.
 
Don't get me started about those stupid light bulbs.
 
subject: Please suggest how to display partial output from time to time using JSP.