Struts 2 Bean Tag Example

In Struts 2, the  “bean” tag is used to create a Java class and place it in the stack’s Context. In this lesson, we will use the “bean” tag to instantiate a Java object inside a JSP page, and then display the content…

Struts 2 Custom Interceptor Example

Generally, the default interceptors are sufficient for most applications, however, we can still create our own interceptor when we need to implement more specific action processing. In this example, we are going to see how to write a custom interceptor…

Struts 2 Default Interceptors Example

  In Struts 2, interceptor is a component that can be plugged in easily to add more processing to the action objects. An interceptor is applied to an action and must be registered in the configuration file. An interceptor runs before…

Struts2 Multiple Configuration Files

  In Struts 2, we can include multiple struts config files into a single file using the <include …/> element, This is useful when we have a project which is divided into different business domains (divide and conquer). In this example we will create…

Struts2 actionerror & actionmessage

  In this example, we will see how to use actionerror tag to display an error message and actionmessage to display an informative message.   1. Technologies used Struts 2.3.16 Maven 3.0.5 Eclipse 4.4 JDK 1.6 Tomcat 6.0   2. Project structure   3. Action class…

Struts2 Multiple Submit Buttons

  In this example, we will see how to use multiple submit buttons within a single form to call multiple methods in the same action.   1. Technologies used Struts 2.3.16 Maven 3.0.5 Eclipse 4.4 JDK 1.6 Tomcat 6.0   2. Project structure  …

Struts2 ModelDriven Example

  In this example, we will see how to use the ModelDriven interface to pass parameters to action through a Java object (Model).   1. Technologies used Struts 2.3.16 Maven 3.0.5 Eclipse 4.4 JDK 1.6 Tomcat 6.0   2. Project structure  …

Struts 2 Annotations Example

  To configure Struts 2 applications (action names, mapping, results,..), we can use either XML file (struts.xml) or annotations. In this example, we will see how to use annotations in Struts 2 application to define and configure an action class….

Struts2 ActionSupport Class

  In this example, we will create a simple Struts2 application with an action that extends the ActionSupport class. ActionSupport is a convenient class that provides a default implementation of many useful interfaces such as Action : So, when an action class extends…