SlideShare a Scribd company logo
1 of 13
Struts Framework 
ExecuteAndWait Interceptor 
Introduction 
Apex T. G. India Pvt. Ltd
1 
execAndWait 
 The ExecuteAndWaitInterceptor is used for running long-lived 
actions in the background while showing the user a 
progress meter(loader image using JavaScript) . 
 This also prevents the HTTP request from timing out when 
the action takes more than 5 or 10 minutes.
1 
execAndWait 
 Using this interceptor is pretty straight forward. 
 Assuming that you are including struts-default.xml, and this 
interceptor is already configured but is not part of any of the 
default stacks then it wont work. 
 Because of the nature of this interceptor, it must be 
the last interceptor in the stack.
1 
execAndWait 
 This interceptor works on a per-session basis. 
 It means, same action name ( DemoAction.class ) cannot be 
run more than once at a time in a given session. On the 
initial request or any subsequent requests (before the action 
has completed), the wait result will be returned. 
 The wait result is responsible for issuing a subsequent 
request back to the action, giving the effect of a self-updating 
progress meter.
1 
execAndWait 
 If no "wait" result is found, Struts will automatically 
generate a wait result on the fly. 
 But this result is written in FreeMarker and cannot run 
unless FreeMarker is installed. 
 If you don't want to use it with FreeMarker then must 
provide a wait page as a result.
1 
execAndWait 
 Whenever the wait result is returned, the action that is 
currently running in the background will be placed on top of 
the stack. 
 This allows you to display progress data, such as a count, in 
the wait page. By making the wait page automatically reload 
the request to the action (which will be short-circuited by 
the interceptor), can give the appearance of an automatic 
progress meter.
1 
execAndWait 
 Whenever the wait result is returned, the action that is 
currently running in the background will be placed on top of 
the stack. 
 This allows you to display progress data, such as a count, in 
the wait page. By making the wait page automatically reload 
the request to the action (which will be short-circuited by 
the interceptor), can give the appearance of an automatic 
progress meter.
1 
execAndWait 
 This interceptor also supports using an initial wait delay. An 
initial delay is a time in milliseconds let the server wait 
before the wait page is shown to the user. 
 During the wait this interceptor will wake every 100 milii 
second to check if the background process is done 
premature, thus if the job for some reason doesn't take to 
long the wait page is not shown to the user.
1 
execAndWait 
 This is useful for e.g. search actions that have a wide span of 
execution time. Using a delay time of 2000 millis we ensure 
the user is presented fast search results immediately and for 
the slow results a wait page is used. 
 Important: Because the action will be running in a separate 
thread, We can't use ActionContext because it is a 
ThreadLocal.
1 
execAndWait 
 The thread kicked off by this interceptor will be named in 
the form actionNameBackgroundProcess. 
 This means if we need to access session data, we need to 
implement SessionAware rather than calling 
ActionContext.getSession().
1 
execAndWait 
 Parameters:threadPriority (optional) - the priority to 
assign the thread. Default is Thread.NORM_PRIORITY. 
 delay (optional) - an initial delay in millis to wait before the 
wait page is shown (returning wait as result code). Default is 
no initial delay. 
 delaySleepInterval (optional) - only used with delay. Used 
for waking up at certain intervals to check if the background 
process is already done. Default is 100 millis.
1 
execAndWait 
<action name=“abc" class="com.abc.DemoAction 
<interceptor-ref name="execAndWait"/> 
<result name="wait">wait.jsp</result> 
<result name="success">success.jsp</result> 
</action>
Thanks 
Stay Connected with us for more chapters on JAVA 
facebook.com/apex.tgi 
twitter.com/ApextgiNoida 
pinterest.com/apextgi

More Related Content

What's hot

Asynchronous programming in .net 4.5 with c#
Asynchronous programming in .net 4.5 with c#Asynchronous programming in .net 4.5 with c#
Asynchronous programming in .net 4.5 with c#Binu Bhasuran
 
Java concurrency in practice
Java concurrency in practiceJava concurrency in practice
Java concurrency in practiceMikalai Alimenkou
 
Command pattern in java
Command pattern in javaCommand pattern in java
Command pattern in javaRakibAhmed0
 
How to debug systemd problems fedora project
How to debug systemd problems   fedora projectHow to debug systemd problems   fedora project
How to debug systemd problems fedora projectSusant Sahani
 
Salesforce interview questions on trigger
Salesforce interview questions on triggerSalesforce interview questions on trigger
Salesforce interview questions on triggerSumit Datta
 
React js use contexts and useContext hook
React js use contexts and useContext hookReact js use contexts and useContext hook
React js use contexts and useContext hookPiyush Jamwal
 
salesforce triggers interview questions and answers
salesforce triggers interview questions and answerssalesforce triggers interview questions and answers
salesforce triggers interview questions and answersbhanuadmob
 
Reactotron - A Debugging Agent
Reactotron -  A Debugging AgentReactotron -  A Debugging Agent
Reactotron - A Debugging AgentMatthieu Vachon
 
Martin Anderson - threads v actors
Martin Anderson - threads v actorsMartin Anderson - threads v actors
Martin Anderson - threads v actorsbloodredsun
 
Creating custom transformer
Creating custom transformerCreating custom transformer
Creating custom transformerRahul Kumar
 
Design patterns - Singleton&Command
Design patterns - Singleton&CommandDesign patterns - Singleton&Command
Design patterns - Singleton&CommandKai Aras
 

What's hot (12)

Asynchronous programming in .net 4.5 with c#
Asynchronous programming in .net 4.5 with c#Asynchronous programming in .net 4.5 with c#
Asynchronous programming in .net 4.5 with c#
 
Java concurrency in practice
Java concurrency in practiceJava concurrency in practice
Java concurrency in practice
 
Introduction+To+Java+Concurrency
Introduction+To+Java+ConcurrencyIntroduction+To+Java+Concurrency
Introduction+To+Java+Concurrency
 
Command pattern in java
Command pattern in javaCommand pattern in java
Command pattern in java
 
How to debug systemd problems fedora project
How to debug systemd problems   fedora projectHow to debug systemd problems   fedora project
How to debug systemd problems fedora project
 
Salesforce interview questions on trigger
Salesforce interview questions on triggerSalesforce interview questions on trigger
Salesforce interview questions on trigger
 
React js use contexts and useContext hook
React js use contexts and useContext hookReact js use contexts and useContext hook
React js use contexts and useContext hook
 
salesforce triggers interview questions and answers
salesforce triggers interview questions and answerssalesforce triggers interview questions and answers
salesforce triggers interview questions and answers
 
Reactotron - A Debugging Agent
Reactotron -  A Debugging AgentReactotron -  A Debugging Agent
Reactotron - A Debugging Agent
 
Martin Anderson - threads v actors
Martin Anderson - threads v actorsMartin Anderson - threads v actors
Martin Anderson - threads v actors
 
Creating custom transformer
Creating custom transformerCreating custom transformer
Creating custom transformer
 
Design patterns - Singleton&Command
Design patterns - Singleton&CommandDesign patterns - Singleton&Command
Design patterns - Singleton&Command
 

Viewers also liked

ExecuteAndWait Interceptor
ExecuteAndWait InterceptorExecuteAndWait Interceptor
ExecuteAndWait InterceptorSeo Trainee
 
Networking overview
Networking overviewNetworking overview
Networking overviewSeo Trainee
 
Networking overview
Networking overviewNetworking overview
Networking overviewSeo Trainee
 
Networking overview part.2
Networking overview part.2Networking overview part.2
Networking overview part.2Seo Trainee
 
Opposites- Exploration Presentation
Opposites- Exploration PresentationOpposites- Exploration Presentation
Opposites- Exploration PresentationClemente17
 
Hair-Pelitos by Sandra Cisneros- Vocabulary
Hair-Pelitos by Sandra Cisneros- VocabularyHair-Pelitos by Sandra Cisneros- Vocabulary
Hair-Pelitos by Sandra Cisneros- VocabularyClemente17
 
Networking overview
Networking overviewNetworking overview
Networking overviewSeo Trainee
 
Te doy mil gracias
Te doy mil graciasTe doy mil gracias
Te doy mil graciasClemente17
 
determine the extent to which wars in afric are a resultof economic reasons
determine the extent to which wars in afric are a resultof economic reasonsdetermine the extent to which wars in afric are a resultof economic reasons
determine the extent to which wars in afric are a resultof economic reasonsRoss Phiri
 
Peluang Usaha Yoghurt
Peluang Usaha YoghurtPeluang Usaha Yoghurt
Peluang Usaha YoghurtRick de Niro
 
The Boy who Cried Wolf
The Boy who Cried WolfThe Boy who Cried Wolf
The Boy who Cried WolfClemente17
 
Things to do in Hawaii
Things to do in HawaiiThings to do in Hawaii
Things to do in HawaiiMiaStellar11
 

Viewers also liked (16)

ExecuteAndWait Interceptor
ExecuteAndWait InterceptorExecuteAndWait Interceptor
ExecuteAndWait Interceptor
 
Prepositions
PrepositionsPrepositions
Prepositions
 
Networking overview
Networking overviewNetworking overview
Networking overview
 
Nouns
NounsNouns
Nouns
 
Networking overview
Networking overviewNetworking overview
Networking overview
 
Networking overview part.2
Networking overview part.2Networking overview part.2
Networking overview part.2
 
Opposites- Exploration Presentation
Opposites- Exploration PresentationOpposites- Exploration Presentation
Opposites- Exploration Presentation
 
Hair-Pelitos by Sandra Cisneros- Vocabulary
Hair-Pelitos by Sandra Cisneros- VocabularyHair-Pelitos by Sandra Cisneros- Vocabulary
Hair-Pelitos by Sandra Cisneros- Vocabulary
 
Networking overview
Networking overviewNetworking overview
Networking overview
 
Te doy mil gracias
Te doy mil graciasTe doy mil gracias
Te doy mil gracias
 
H
HH
H
 
determine the extent to which wars in afric are a resultof economic reasons
determine the extent to which wars in afric are a resultof economic reasonsdetermine the extent to which wars in afric are a resultof economic reasons
determine the extent to which wars in afric are a resultof economic reasons
 
Project
ProjectProject
Project
 
Peluang Usaha Yoghurt
Peluang Usaha YoghurtPeluang Usaha Yoghurt
Peluang Usaha Yoghurt
 
The Boy who Cried Wolf
The Boy who Cried WolfThe Boy who Cried Wolf
The Boy who Cried Wolf
 
Things to do in Hawaii
Things to do in HawaiiThings to do in Hawaii
Things to do in Hawaii
 

Similar to Execute andwait

Performance Test Plan - Sample 1
Performance Test Plan - Sample 1Performance Test Plan - Sample 1
Performance Test Plan - Sample 1Atul Pant
 
What is the difference between struts 1 vs struts 2
What is the difference between struts 1 vs struts 2What is the difference between struts 1 vs struts 2
What is the difference between struts 1 vs struts 2Santosh Singh Paliwal
 
Servlets - filter, listeners, wrapper, internationalization
Servlets -  filter, listeners, wrapper, internationalizationServlets -  filter, listeners, wrapper, internationalization
Servlets - filter, listeners, wrapper, internationalizationsusant sahu
 
Sagas Middleware Architecture
Sagas Middleware ArchitectureSagas Middleware Architecture
Sagas Middleware ArchitectureMateusz Bosek
 
Java util concurrent
Java util concurrentJava util concurrent
Java util concurrentRoger Xia
 
Day1_Apache_JMeter_Overview
Day1_Apache_JMeter_OverviewDay1_Apache_JMeter_Overview
Day1_Apache_JMeter_OverviewSravanthi N
 
Azure Function Workflow
Azure Function WorkflowAzure Function Workflow
Azure Function WorkflowAndrea Tosato
 
Building resilient applications
Building resilient applicationsBuilding resilient applications
Building resilient applicationsNuno Caneco
 
Iasi code camp 12 october 2013 performance testing for web applications with...
Iasi code camp 12 october 2013  performance testing for web applications with...Iasi code camp 12 october 2013  performance testing for web applications with...
Iasi code camp 12 october 2013 performance testing for web applications with...Codecamp Romania
 
A Project Run@Timer, J2SE,
A Project Run@Timer, J2SE,A Project Run@Timer, J2SE,
A Project Run@Timer, J2SE,Swapnil Dubey
 
Jmeter interviewquestions
Jmeter interviewquestionsJmeter interviewquestions
Jmeter interviewquestionsgirichinna27
 
Waits alerts and switch windows
Waits alerts and switch windowsWaits alerts and switch windows
Waits alerts and switch windowsDucat
 
UVM Driver sequencer handshaking
UVM Driver sequencer handshakingUVM Driver sequencer handshaking
UVM Driver sequencer handshakingHARINATH REDDY
 
Automation testing by Durgasoft in Hyderabad
Automation testing by Durgasoft in HyderabadAutomation testing by Durgasoft in Hyderabad
Automation testing by Durgasoft in HyderabadDurga Prasad
 
Automation testing material by Durgasoft,hyderabad
Automation testing material by Durgasoft,hyderabadAutomation testing material by Durgasoft,hyderabad
Automation testing material by Durgasoft,hyderabadDurga Prasad
 

Similar to Execute andwait (20)

Performance Test Plan - Sample 1
Performance Test Plan - Sample 1Performance Test Plan - Sample 1
Performance Test Plan - Sample 1
 
What is the difference between struts 1 vs struts 2
What is the difference between struts 1 vs struts 2What is the difference between struts 1 vs struts 2
What is the difference between struts 1 vs struts 2
 
Servlets - filter, listeners, wrapper, internationalization
Servlets -  filter, listeners, wrapper, internationalizationServlets -  filter, listeners, wrapper, internationalization
Servlets - filter, listeners, wrapper, internationalization
 
Tech talk
Tech talkTech talk
Tech talk
 
Sagas Middleware Architecture
Sagas Middleware ArchitectureSagas Middleware Architecture
Sagas Middleware Architecture
 
Java util concurrent
Java util concurrentJava util concurrent
Java util concurrent
 
AMC Minor Technical Issues
AMC Minor Technical IssuesAMC Minor Technical Issues
AMC Minor Technical Issues
 
Day1_Apache_JMeter_Overview
Day1_Apache_JMeter_OverviewDay1_Apache_JMeter_Overview
Day1_Apache_JMeter_Overview
 
Azure Function Workflow
Azure Function WorkflowAzure Function Workflow
Azure Function Workflow
 
Building resilient applications
Building resilient applicationsBuilding resilient applications
Building resilient applications
 
G pars
G parsG pars
G pars
 
Iasi code camp 12 october 2013 performance testing for web applications with...
Iasi code camp 12 october 2013  performance testing for web applications with...Iasi code camp 12 october 2013  performance testing for web applications with...
Iasi code camp 12 october 2013 performance testing for web applications with...
 
A Project Run@Timer, J2SE,
A Project Run@Timer, J2SE,A Project Run@Timer, J2SE,
A Project Run@Timer, J2SE,
 
Jmeter interviewquestions
Jmeter interviewquestionsJmeter interviewquestions
Jmeter interviewquestions
 
Waits alerts and switch windows
Waits alerts and switch windowsWaits alerts and switch windows
Waits alerts and switch windows
 
UVM Driver sequencer handshaking
UVM Driver sequencer handshakingUVM Driver sequencer handshaking
UVM Driver sequencer handshaking
 
J2EE-assignment
 J2EE-assignment J2EE-assignment
J2EE-assignment
 
Automation testing by Durgasoft in Hyderabad
Automation testing by Durgasoft in HyderabadAutomation testing by Durgasoft in Hyderabad
Automation testing by Durgasoft in Hyderabad
 
Automation testing material by Durgasoft,hyderabad
Automation testing material by Durgasoft,hyderabadAutomation testing material by Durgasoft,hyderabad
Automation testing material by Durgasoft,hyderabad
 
JavaCro'15 - Spring @Async - Dragan Juričić
JavaCro'15 - Spring @Async - Dragan JuričićJavaCro'15 - Spring @Async - Dragan Juričić
JavaCro'15 - Spring @Async - Dragan Juričić
 

Execute andwait

  • 1. Struts Framework ExecuteAndWait Interceptor Introduction Apex T. G. India Pvt. Ltd
  • 2. 1 execAndWait  The ExecuteAndWaitInterceptor is used for running long-lived actions in the background while showing the user a progress meter(loader image using JavaScript) .  This also prevents the HTTP request from timing out when the action takes more than 5 or 10 minutes.
  • 3. 1 execAndWait  Using this interceptor is pretty straight forward.  Assuming that you are including struts-default.xml, and this interceptor is already configured but is not part of any of the default stacks then it wont work.  Because of the nature of this interceptor, it must be the last interceptor in the stack.
  • 4. 1 execAndWait  This interceptor works on a per-session basis.  It means, same action name ( DemoAction.class ) cannot be run more than once at a time in a given session. On the initial request or any subsequent requests (before the action has completed), the wait result will be returned.  The wait result is responsible for issuing a subsequent request back to the action, giving the effect of a self-updating progress meter.
  • 5. 1 execAndWait  If no "wait" result is found, Struts will automatically generate a wait result on the fly.  But this result is written in FreeMarker and cannot run unless FreeMarker is installed.  If you don't want to use it with FreeMarker then must provide a wait page as a result.
  • 6. 1 execAndWait  Whenever the wait result is returned, the action that is currently running in the background will be placed on top of the stack.  This allows you to display progress data, such as a count, in the wait page. By making the wait page automatically reload the request to the action (which will be short-circuited by the interceptor), can give the appearance of an automatic progress meter.
  • 7. 1 execAndWait  Whenever the wait result is returned, the action that is currently running in the background will be placed on top of the stack.  This allows you to display progress data, such as a count, in the wait page. By making the wait page automatically reload the request to the action (which will be short-circuited by the interceptor), can give the appearance of an automatic progress meter.
  • 8. 1 execAndWait  This interceptor also supports using an initial wait delay. An initial delay is a time in milliseconds let the server wait before the wait page is shown to the user.  During the wait this interceptor will wake every 100 milii second to check if the background process is done premature, thus if the job for some reason doesn't take to long the wait page is not shown to the user.
  • 9. 1 execAndWait  This is useful for e.g. search actions that have a wide span of execution time. Using a delay time of 2000 millis we ensure the user is presented fast search results immediately and for the slow results a wait page is used.  Important: Because the action will be running in a separate thread, We can't use ActionContext because it is a ThreadLocal.
  • 10. 1 execAndWait  The thread kicked off by this interceptor will be named in the form actionNameBackgroundProcess.  This means if we need to access session data, we need to implement SessionAware rather than calling ActionContext.getSession().
  • 11. 1 execAndWait  Parameters:threadPriority (optional) - the priority to assign the thread. Default is Thread.NORM_PRIORITY.  delay (optional) - an initial delay in millis to wait before the wait page is shown (returning wait as result code). Default is no initial delay.  delaySleepInterval (optional) - only used with delay. Used for waking up at certain intervals to check if the background process is already done. Default is 100 millis.
  • 12. 1 execAndWait <action name=“abc" class="com.abc.DemoAction <interceptor-ref name="execAndWait"/> <result name="wait">wait.jsp</result> <result name="success">success.jsp</result> </action>
  • 13. Thanks Stay Connected with us for more chapters on JAVA facebook.com/apex.tgi twitter.com/ApextgiNoida pinterest.com/apextgi