Re: [Stripes-users] Writing to response.writer is not working

2016-01-23 Thread Joaquin Valdez
Hi!

Is this the same idea as this: 

https://stripesframework.atlassian.net/wiki/display/STRIPES/Wait+Page+for+Long+Events
 ?

Joaquin 

> On Jan 23, 2016, at 10:52 AM, VANKEISBELCK Remi  wrote:
> 
> Hi again,
> 
> Seems like a regular "long running job / polling" scenario. It can be done 
> with current Stripes version, even if it will be less performant if your http 
> client is really non blocking, but that's another story.
> 
> So here's how I'd do this.
> 
> 1/ Server side
> 
> In the ActionBean, I'd submit a task to an executor service (a thread pool) 
> with that long running job that calls the webservice. This task should update 
> the back-end state in some way, so that you can do polling and know when it's 
> done. 
> The same ActionBean can handle Ajax polling via another event method. This 
> one will be called from some JS code in your page.
> 
> public class MyAction implements ActionBean {
> 
>   public Resolution triggerLongRunningJob() {
> // retrieve Executor Service, from servlet context or custom 
> ActionBeanContext
> ExecutorService executorService = ... ; 
> // submit task
> executorService.submit(new MyLongRunningTask(...);
> // return a redirect resolution to the "wait" screen
> return new RedirectResolution(getClass(), "displayWaitScreen")
>   }
> 
>   public Resolution displayWaitScreen() {
> return new ForwardResolution("/WEB-INF/jsp/wait-screen.jsp");
>   }
> 
>   public Resolution poll() {
> // find task completion status and return to the client
> String jsonTaskCompletion = ... ;
> return new StreamingResolution("application/json", jsonTaskCompletion);
>   }
> 
> 
>   // the long running task code is in a Runnable
>   private class MyLongRunningTask implements Runnable {
> public void run() {
>   // call the webservice and update internal state
> 
> }
>   }
> }
> 
> 
> 2/ Client side
> 
> First you'll submit the form to the 'triggerLongRunningJob' event. This will 
> launch the background task and return directly. 
> Then, you'll send xhr requests to the 'poll' event, that will tell you what 
> to do next. If task has completed, then you'll probably change the location 
> of the browser in some way in order to display a "result" page of some sort 
> (ie use your data from the completed task and do whatever you need with it).
> 
> HTH
> 
> Rémi
> 
>  
> 
> 
> 
> 2016-01-23 17:05 GMT+01:00 Ron King :
>> Hi everyone,
>> 
>> I want to write an html page back to the user at the very beginning of an 
>> ActionBean submit method.
>> The method calls a web service that takes around a minute to respond, and I 
>> want to put up a message
>> before the web service finishes.
>> 
>> I'm on Tomcat 8. I tried flushing the writer, but the page still doesn't 
>> display until after I return the
>> Resolution from the submit method.
>> 
>> Is there a way to make it write immediately?
>> 
>> Regards,
>> 
>> Ron
>> 
>> --
>> Site24x7 APM Insight: Get Deep Visibility into Application Performance
>> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
>> Monitor end-to-end web transactions and take corrective actions now
>> Troubleshoot faster and improve end-user experience. Signup Now!
>> http://pubads.g.doubleclick.net/gampad/clk?id=267308311=/4140
>> ___
>> Stripes-users mailing list
>> Stripes-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/stripes-users
> 
> --
> Site24x7 APM Insight: Get Deep Visibility into Application Performance
> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
> Monitor end-to-end web transactions and take corrective actions now
> Troubleshoot faster and improve end-user experience. Signup Now!
> http://pubads.g.doubleclick.net/gampad/clk?id=267308311=/4140
> ___
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users
--
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311=/4140___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


Re: [Stripes-users] Writing to response.writer is not working

2016-01-23 Thread VANKEISBELCK Remi
Hi again,

Seems like a regular "long running job / polling" scenario. It can be done
with current Stripes version, even if it will be less performant if your
http client is really non blocking, but that's another story.

So here's how I'd do this.

1/ Server side

In the ActionBean, I'd submit a task to an executor service (a thread pool)
with that long running job that calls the webservice. This task should
update the back-end state in some way, so that you can do polling and know
when it's done.
The same ActionBean can handle Ajax polling via another event method. This
one will be called from some JS code in your page.

public class MyAction implements ActionBean {

  public Resolution triggerLongRunningJob() {
// retrieve Executor Service, from servlet context or custom
ActionBeanContext
ExecutorService executorService = ... ;
// submit task
executorService.submit(new MyLongRunningTask(...);
// return a redirect resolution to the "wait" screen
return new RedirectResolution(getClass(), "displayWaitScreen")
  }

  public Resolution displayWaitScreen() {
return new ForwardResolution("/WEB-INF/jsp/wait-screen.jsp");
  }

  public Resolution poll() {
// find task completion status and return to the client
String jsonTaskCompletion = ... ;
return new StreamingResolution("application/json", jsonTaskCompletion);
  }


  // the long running task code is in a Runnable
  private class MyLongRunningTask implements Runnable {
public void run() {
  // call the webservice and update internal state

}
  }
}


2/ Client side

First you'll submit the form to the 'triggerLongRunningJob' event. This
will launch the background task and return directly.
Then, you'll send xhr requests to the 'poll' event, that will tell you what
to do next. If task has completed, then you'll probably change the location
of the browser in some way in order to display a "result" page of some sort
(ie use your data from the completed task and do whatever you need with it).

HTH

Rémi





2016-01-23 17:05 GMT+01:00 Ron King :

> Hi everyone,
>
> I want to write an html page back to the user at the very beginning of an
> ActionBean submit method.
> The method calls a web service that takes around a minute to respond, and
> I want to put up a message
> before the web service finishes.
>
> I'm on Tomcat 8. I tried flushing the writer, but the page still doesn't
> display until after I return the
> Resolution from the submit method.
>
> Is there a way to make it write immediately?
>
> Regards,
>
> Ron
>
>
> --
> Site24x7 APM Insight: Get Deep Visibility into Application Performance
> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
> Monitor end-to-end web transactions and take corrective actions now
> Troubleshoot faster and improve end-user experience. Signup Now!
> http://pubads.g.doubleclick.net/gampad/clk?id=267308311=/4140
> ___
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
--
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311=/4140___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users