Struts 2 requiredstring validator

The required validator is used check that the specified string field can’t be null and should have length greater than 0. Plain validator syntax of requiredstring validator. <validators> <validator type="requiredstring"> <param name="fieldName">fieldName</param> <param name="trim">true</param> <message>message string</message> </validator> </validators><validators> <validator type="requiredstring"> <param name="fieldName">fieldName</param> <param name="trim">true</param> <message>message string</message> </validator> </validators> Field validator syntax of requiredstring validator. <validators> … Read more

Struts 2 required validator

The required validator is used check that the specified field can’t be null. Plain validator syntax of required validator. <validators> <validator type="required"> <param name="fieldName">fieldName </param> <message>message string</message> </validator> </validators><validators> <validator type="required"> <param name="fieldName">fieldName </param> <message>message string</message> </validator> </validators> Field validator syntax of required validator. <validators> <field name="fieldName "> <field-validator type="required"> <message>message string</message> </field-validator> </field> </validators><validators> … Read more

Struts 2 validation by built-in validators

Struts 2 validation framework provides many generic built-in validators to perform various validations like email validation, required validation, stringlength validation etc. These validations are also known as XML based validation. Built-in validators are placed in an xml file. The name of the xml file should be like actionClassName-validation.xml. Note: No need to specify any validate() … Read more

Struts 2 validation framework

Validation: Validation is a process of checking something against a standard. Struts 2 validation framework: Struts 2 validation framework provides many generic built-in validation methods or validators to perform various validations. It enables the web container to perform validation rules before executing the actions. We can also create custom validators. Ways of performing validations in … Read more

Struts 2 Redirect result type

Redirect result type: Redirect result type creates a new request by calling response.sendRedirect() method. Struts 2 Redirect result type example: login.jsp <%@ taglib uri="/struts-tags" prefix="s"%> <html> <head> <title>Struts 2 redirect result type example</title> </head> <body> <h3>This is a redirect result type example.</h3>   <s:form action="Login"> <s:textfield name="userName" label="UserName" /> <s:submit value="Hello" align="center"/> </s:form>   </body> … Read more

Struts 2 result type

When request comes, business logic is executed first and after that result is displayed as view. Struts provides a number of predefined result types. The dispatcher is the default result type. The <results> tag is used to specify a result type in sturts.xml. The dispatcher, FreeMaker and redirect are the commonly used result types. Struts … Read more

Struts 2 custom interceptor

We can create a custom interceptor in struts 2. To create a custom interceptor implements the Interceptor interface. Interceptor interface provides the methods to create a custom interceptor. Methods of Interceptor interface: 1. init(): It is used to initialize the interceptor. It is called only once by the web container. public void init() 2. intercept(ActionInvocation … Read more

Struts 2 execAndWait interceptor

execAndWait interceptor: The execAndWait interceptor is used in case of long running action. It sends the user to an intermediate waiting page while action is executed. Note: We have to put the meta refresh tag on the top of the waiting page so that waiting page will redirect to the required result page. Struts 2 … Read more

Interceptors in struts 2

Interceptors: Interceptor is an object which is called at the pre processing and post processing of a request. These are same as the filters in the servlet. Use of interceptors in struts 2. Interceptors are used to perform some pre-processing task before the action is invoked. Interceptors are used to perform some post-processing task after … Read more

Value Stack in struts 2

Valuestack in struts2 pdf download. In struts 2 ValueStack represents a stack that contains the references of application specific objects. When a request come an object of ValueStack is created first and after it object of Action, Model or any other java resources are created. The references of all these objects are maintained in ValueStack. … Read more