No there's no issue using an ExecutorService inside a container. Most
frameworks use their own thread pools today.

Just create it in an init context listener or something like this, and
shutdown it properly when the app closes.

Cheers

Rémi

2016-01-26 17:23 GMT+01:00 Ron King <ronck...@gmail.com>:

> Remi, from some of my reading, I'm getting the impression
> that one should be careful when using threads inside of a
> servlet container. How do you do this, can you elaborate?
>
> On Tue, Jan 26, 2016 at 9:23 AM, <
> stripes-users-requ...@lists.sourceforge.net> wrote:
>
>> Send Stripes-users mailing list submissions to
>>         stripes-users@lists.sourceforge.net
>>
>> To subscribe or unsubscribe via the World Wide Web, visit
>>         https://lists.sourceforge.net/lists/listinfo/stripes-users
>> or, via email, send a message with subject or body 'help' to
>>         stripes-users-requ...@lists.sourceforge.net
>>
>> You can reach the person managing the list at
>>         stripes-users-ow...@lists.sourceforge.net
>>
>> When replying, please edit your Subject line so it is more specific
>> than "Re: Contents of Stripes-users digest..."
>>
>>
>> Today's Topics:
>>
>>    1. Re: Flushing a writer before the ActionBean has   completed
>>       (Ron King)
>>
>>
>> ----------------------------------------------------------------------
>>
>> Message: 1
>> Date: Tue, 26 Jan 2016 09:23:06 -0600
>> From: Ron King <ronck...@gmail.com>
>> Subject: Re: [Stripes-users] Flushing a writer before the ActionBean
>>         has     completed
>> To: stripes-users@lists.sourceforge.net
>> Message-ID:
>>         <
>> can2l1vr_sxg8xo13fun2-vo82r6r2rqvxw5jf0gxjpdezjj...@mail.gmail.com>
>> Content-Type: text/plain; charset="utf-8"
>>
>> Thanks Remi, I'll give this some thought, this helps a lot.
>> Also, I did come up with a way to prompt the user at the beginning of the
>> submission.
>> I pop up a jquery-ui dialog box, instead of trying to use the response
>> writer
>> to write a new page.
>>
>> On Tue, Jan 26, 2016 at 2:15 AM, <
>> stripes-users-requ...@lists.sourceforge.net> wrote:
>>
>> > Send Stripes-users mailing list submissions to
>> >         stripes-users@lists.sourceforge.net
>> >
>> > To subscribe or unsubscribe via the World Wide Web, visit
>> >         https://lists.sourceforge.net/lists/listinfo/stripes-users
>> > or, via email, send a message with subject or body 'help' to
>> >         stripes-users-requ...@lists.sourceforge.net
>> >
>> > You can reach the person managing the list at
>> >         stripes-users-ow...@lists.sourceforge.net
>> >
>> > When replying, please edit your Subject line so it is more specific
>> > than "Re: Contents of Stripes-users digest..."
>> >
>> >
>> > Today's Topics:
>> >
>> >    1. Re: Stripes-users Digest, Vol 113, Issue 4 (VANKEISBELCK Remi)
>> >
>> >
>> > ----------------------------------------------------------------------
>> >
>> > Message: 1
>> > Date: Tue, 26 Jan 2016 09:15:03 +0100
>> > From: VANKEISBELCK Remi <r...@rvkb.com>
>> > Subject: Re: [Stripes-users] Stripes-users Digest, Vol 113, Issue 4
>> > To: Stripes Users List <stripes-users@lists.sourceforge.net>
>> > Message-ID:
>> >         <CAG-EEs3GhOKEUHRZBMWpZvp7bnBz=
>> > kuwkyvpng2sp4kr_qk...@mail.gmail.com>
>> > Content-Type: text/plain; charset="utf-8"
>> >
>> > Hi Ron,
>> >
>> > Sending an email at the end of the task is even easier : you don't need
>> > polling at all !
>> >
>> > Simply submit a runnable with your webservice call and response handling
>> > (send the email) to an ExecutorService from the action. This is "fire
>> and
>> > forget" : submission to the executor doesn't block. Then just return a
>> > redirect to the action you want.
>> >
>> > Stuff like :
>> >
>> > public Resolution submitTaskAndProceed() {
>> >   executorService.submit(new MyTask(this));
>> >   return new RedirectResolution(MyActionAfterSubmitTask.class);
>> > }
>> >
>> > As you see the action can be an argument of the task, in case you need
>> it.
>> > I prefer to pass actual required data as it makes your task testable
>> > outside of Stripes.
>> >
>> > The whole point here is that your action bean is a regular one. It
>> submits
>> > a job to a thread pool, that's all.
>> >
>> > HTH
>> >
>> > R?mi
>> >
>> > 2016-01-25 17:54 GMT+01:00 Ron King <ronck...@gmail.com>:
>> >
>> > > The link that Joaquin describes is not quite what I want either. I
>> want
>> > to
>> > > allow the user to go ahead and
>> > > continue to work, not wait one minute before they can go on. This
>> seems
>> > to
>> > > describe a scenario where a 'wait page' would be updated periodically,
>> > and
>> > > I don't want the user to have to wait at all. Sending an email from
>> > within
>> > > the action upon completion would work for me as far as notifying the
>> user
>> > > about their form submission.
>> > >
>> > > It appears to me that If I can get the response writer to write out my
>> > new
>> > > page at the beginning of the submission, it would satisfy my
>> requirement.
>> > > How can I ensure that the writer is flushed?
>> > >
>> > >
>> > >
>> >
>> https://stripesframework.atlassian.net/wiki/display/STRIPES/Wait+Page+for+Long+Events
>> > >
>> > > On Mon, Jan 25, 2016 at 3:00 AM, <
>> > > stripes-users-requ...@lists.sourceforge.net> wrote:
>> > >
>> > >> Send Stripes-users mailing list submissions to
>> > >>         stripes-users@lists.sourceforge.net
>> > >>
>> > >> To subscribe or unsubscribe via the World Wide Web, visit
>> > >>         https://lists.sourceforge.net/lists/listinfo/stripes-users
>> > >> or, via email, send a message with subject or body 'help' to
>> > >>         stripes-users-requ...@lists.sourceforge.net
>> > >>
>> > >> You can reach the person managing the list at
>> > >>         stripes-users-ow...@lists.sourceforge.net
>> > >>
>> > >> When replying, please edit your Subject line so it is more specific
>> > >> than "Re: Contents of Stripes-users digest..."
>> > >>
>> > >>
>> > >> Today's Topics:
>> > >>
>> > >>    1. Re: Writing to response.writer is not working (Joaquin Valdez)
>> > >>    2. Re: Infinite loop issue on stripes layout components inside
>> > >>       jsp tag (Zlatka Mihaylova)
>> > >>
>> > >>
>> > >>
>> ----------------------------------------------------------------------
>> > >>
>> > >> Message: 1
>> > >> Date: Sat, 23 Jan 2016 11:41:57 -0700
>> > >> From: Joaquin Valdez <joaquinfval...@gmail.com>
>> > >> Subject: Re: [Stripes-users] Writing to response.writer is not
>> working
>> > >> To: r...@rvkb.com, Stripes Users List
>> > >>         <stripes-users@lists.sourceforge.net>
>> > >> Message-ID: <c434177a-267a-42a6-be86-4bf7d6b64...@gmail.com>
>> > >> Content-Type: text/plain; charset="utf-8"
>> > >>
>> > >> 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 <r...@rvkb.com>
>> > 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 <ronck...@gmail.com>:
>> > >> >> 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&iu=/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&iu=/4140
>> > >> > _______________________________________________
>> > >> > Stripes-users mailing list
>> > >> > Stripes-users@lists.sourceforge.net
>> > >> > https://lists.sourceforge.net/lists/listinfo/stripes-users
>> > >> -------------- next part --------------
>> > >> An HTML attachment was scrubbed...
>> > >>
>> > >> ------------------------------
>> > >>
>> > >> Message: 2
>> > >> Date: Mon, 25 Jan 2016 08:45:32 +0000
>> > >> From: Zlatka Mihaylova <zla...@chrono24.com>
>> > >> Subject: Re: [Stripes-users] Infinite loop issue on stripes layout
>> > >>         components inside jsp tag
>> > >> To: Stripes Users List <stripes-users@lists.sourceforge.net>
>> > >> Message-ID: <ca5a61b5677b427c9dfc34af0c2ba...@dox13be02.hex2013.com>
>> > >> Content-Type: text/plain; charset="utf-8"
>> > >>
>> > >> Thank you for the solution. It works.
>> > >> Btw, is there a Stripes change log somewhere? I?m interested in the
>> > >> changes from the last 7-8 years.
>> > >>
>> > >> Von: Ben Gunter [mailto:bgun...@cpons.com]
>> > >> Gesendet: Mittwoch, 20. Januar 2016 13:12
>> > >> An: Stripes Users List <stripes-users@lists.sourceforge.net>
>> > >> Betreff: Re: [Stripes-users] Infinite loop issue on stripes layout
>> > >> components inside jsp tag
>> > >>
>> > >> There's no telling when or if this will get fixed. For now, you
>> should
>> > be
>> > >> able to work around the issue by using the alternative layout tag
>> > >> implementation with the following URL in the taglib directive:
>> > >>
>> > >> <%@ taglib prefix="layout" uri="
>> > >> http://stripes.sourceforge.net/stripes-buffered-layout.tld"; %>
>> > >>
>> > >> On Wed, Jan 20, 2016 at 5:53 AM, Zlatka Mihaylova <
>> zla...@chrono24.com
>> > >> <mailto:zla...@chrono24.com>> wrote:
>> > >> Hi,
>> > >>
>> > >> I am stuck on the following problem: with the current stripes version
>> > >> 1.6.0 an infinite recursion occurs whenever a
>> > <stripes:layout-component> is
>> > >> rendered inside a JSP custom tag. It?s pretty much the same issue
>> > reported
>> > >> here: https://stripesframework.atlassian.net/browse/STS-924 . The
>> > >> solution to rewrite all custom tags into JSP includes is working, but
>> > >> unclean, since we lose the convenient component encapsulation. This
>> bug
>> > >> makes it impossible to use stripes layouts inside custom JSP tags.
>> > >>
>> > >> One of the stripes framework strengths is in the layout reusability.
>> > >> Therefore it would be very helpful if the issue is reopened and
>> fixed.
>> > Let
>> > >> me know if you need more information or sample program to reproduce
>> the
>> > >> problem.
>> > >> Kind regards
>> > >>
>> > >> Zlatka Mihaylova
>> > >> Backend-/ Java Developer
>> > >>
>> > >>
>> > >>
>> >
>> ------------------------------------------------------------------------------
>> > >> 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&iu=/4140
>> > >> _______________________________________________
>> > >> Stripes-users mailing list
>> > >> Stripes-users@lists.sourceforge.net<mailto:
>> > >> Stripes-users@lists.sourceforge.net>
>> > >> https://lists.sourceforge.net/lists/listinfo/stripes-users
>> > >>
>> > >> -------------- next part --------------
>> > >> An HTML attachment was scrubbed...
>> > >>
>> > >> ------------------------------
>> > >>
>> > >>
>> > >>
>> >
>> ------------------------------------------------------------------------------
>> > >> 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&iu=/4140
>> > >>
>> > >> ------------------------------
>> > >>
>> > >> _______________________________________________
>> > >> Stripes-users mailing list
>> > >> Stripes-users@lists.sourceforge.net
>> > >> https://lists.sourceforge.net/lists/listinfo/stripes-users
>> > >>
>> > >>
>> > >> End of Stripes-users Digest, Vol 113, Issue 4
>> > >> *********************************************
>> > >>
>> > >
>> > >
>> > >
>> > >
>> >
>> ------------------------------------------------------------------------------
>> > > 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&iu=/4140
>> > > _______________________________________________
>> > > Stripes-users mailing list
>> > > Stripes-users@lists.sourceforge.net
>> > > https://lists.sourceforge.net/lists/listinfo/stripes-users
>> > >
>> > >
>> > -------------- next part --------------
>> > An HTML attachment was scrubbed...
>> >
>> > ------------------------------
>> >
>> >
>> >
>> ------------------------------------------------------------------------------
>> > 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&iu=/4140
>> >
>> > ------------------------------
>> >
>> > _______________________________________________
>> > Stripes-users mailing list
>> > Stripes-users@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/stripes-users
>> >
>> >
>> > End of Stripes-users Digest, Vol 113, Issue 8
>> > *********************************************
>> >
>> -------------- next part --------------
>> An HTML attachment was scrubbed...
>>
>> ------------------------------
>>
>>
>> ------------------------------------------------------------------------------
>> 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&iu=/4140
>>
>> ------------------------------
>>
>> _______________________________________________
>> Stripes-users mailing list
>> Stripes-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>>
>>
>> End of Stripes-users Digest, Vol 113, Issue 9
>> *********************************************
>>
>
>
>
> ------------------------------------------------------------------------------
> 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&iu=/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&iu=/4140
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to