Struts 2 TextField Tag Example

struts2-thumbnail

Struts 2 s:textfield is the equivalent of input text box in the HTML. This tutorial shows how to take the input from a JSP file and pass on to the next field using Struts 2 Action class. Lets see the example. 1. Action Class A simple action class for taking the employee name from user. […]

Struts 2 Include Tag Example

struts2-thumbnail

Struts 2 Include Tag helpful for directly inserting another JSP or HTML page to the current page. This tutorial shows how to use the include tag. 1. Action Class 2. Include Tag Example IncludeTag.jsp Output.jsp 3. Struts.xml

Struts 2 Push Tag Example

struts2-thumbnail

Struts 2 Push Tag pushes the values to top of the stack. Once the push tag pushes the values, then those fields can be easily accessed without the bean references. Lets see the below example for how to use the push tag. 1. Action Class and Bean Struts2HelloWorldAction.java UserDetails.java 2. Push Tag Example 3. Struts.xml […]

Struts 2 Property Tag Example

struts2-thumbnail

Struts 2 Property Tag is most commonly used by the struts applications. It is simply taking the field or property values from the bean instances or from the context variables. This tag can be used either as sub element of another tag or outside any other tags. This tutorial shows how to use the s:property […]

Struts 2 Date Tag Example

struts2-thumbnail

Struts 2 date tag formats the date string in two ways, one is by converting to the required format and second is by using the “nice” attribute and converting to the human readable format. This tutorials shows how to use the s:date tag for converting to the different formats for the same input. 1. Action […]

Struts 2 Bean Tag Example

struts2-thumbnail

Struts 2 Bean Tag is helpful for assigning a bean reference to the JSP page. Using the s:param attribute, you can pass the values to the bean reference and set the values. After this tag is executed, you can use the bean instance throughout the page. 1. Action Class and Bean Struts2HelloWorldAction.java UserDetails.java 2. Bean […]

Struts 2 Action Tag Example

struts2-thumbnail

Struts 2 action tag is helpful for executing an action and inserting the result in a particular location of the web page. There are two options with action tag, if the value for the executeResult is set to “true”, then the result is displayed to the page as it is defined in that target view. […]

Difference Between FilterDispatcher and StrutsPrepareAndExecuteFilter in Struts 2

struts2-thumbnail

If you are working on the Struts 2 applications, you would have noticed that while configuring the Struts 2 filter in your web.xml deployment descriptor, there is two different classes are used. One is org.apache.struts2.dispatcher.FilterDispatcher and another one is org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter. The simple answer is, org.apache.struts2.dispatcher.FilterDispatcher – Used in the early development of Struts 2 and […]

Struts 2 Control Tags

struts2-thumbnail

Struts 2 provides list of conditional or control tags which is very useful for controlling the flow of an application. The following are the list of important tags listed under conditional tags. If and else Iterator Merge Append Generator 1. The if and else tags This tag is useful for executing the simple if or […]

Struts 2 Generator Tag Example

struts2-thumbnail

Struts 2 generator tag takes inline array or list of values and pass to the s:iterator to loop through the list of values. 1. Create Struts 2 Action Create ¬†action class. 2. Generator Tag Example Write JSP with generator tag to display the list of values. 3. Struts.xml configurations Write struts.xml configuration file. 4. Run […]