Javatpoint Logo
Javatpoint Logo

Struts 2 execAndWait interceptor example

The execAndWait interceptor also known as execute and wait interceptor is used to display the intermediate result.

It is recommended to use for long running action.

It is not found in the default stack bydefault. So you need to specify it explicitely.

If you don't specify "wait" result, struts framework displays an intermediate result until your request is completed.

For the custom intermediate result, you need to define "wait" result in struts.xml file. In your page, you can display processing image etc. So, it is better to specify the custom result.

Parameters of execAndWait interceptor

There are 3 parameters defined for execAndWait interceptor.

ParameterDescription
delay specifies the initial delay time. Bydefault, no initial delay is set.
delaySleepInterval used only with delay. It specifies the time interval in milliseconds to check that background process is completed. It is set to 100 milliseconds bydefault.
threadPriority specifies the priority of the thread. The default is Thread.NORM_PRIORITY.

Example of execAndWait interceptor without wait result

Let's see the simple example of execAndWait interceptor without wait result. In such case, struts framework provides an intermediate result.

Example of execAndWait interceptor with wait result

Let's see the simple example of execAndWait interceptor with wait result. In such case, your intermediate page is invoked.


myintermediatepage.jsp

Let's write the code for intermediate result. The s:url tag will forward the request to specified url.

It will be refreshed at 0.5 seconds.

Output

struts 2 execandwait example output 1 struts 2 execandwait example output 2 struts 2 execandwait example output 3 struts 2 execandwait example output 4



Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


B.Tech / MCA