Temporary Objects − There are various temporary objects which are created during execution of a page. For example the current iteration value for a collection being looped over in a JSP tag.
The Model Object − If you are using model objects in your struts application, the current model object is placed before the action on the value stack.
The Action Object − This will be the current action object which is being executed.
Named Objects − These objects include #application, #session, #request, #attr and #parameters and refer to the corresponding servlet scopes.
22.What is OGNL?
The Object-Graph Navigation Language (OGNL) is a powerful expression language that is used to reference and manipulate data on the ValueStack. OGNL also helps in data transfer and type conversion.
23.Which components are available using ActionContext map?
The ActionContext map consists of the following −
application − application scoped variables.
session − session scoped variables.
root / value stack − all your action variables are stored here.
request − request scoped variables.
parameters − request parameters.
atributes − the attributes stored in page, request, session and application scope.
24.Which interceptor is responsible for file upload support?
File uploading in Struts is possible through a pre-defined interceptor called FileUpload interceptor which is available through the org.apache.struts2.interceptor.FileUploadInterceptor class and included as part of the defaultStack.
25.What are the Struts2 configuration properties that control file uploading process?
Following are the Struts2 configuration properties that control file uploading process −
struts.multipart.maxSize − The maximum size (in bytes) of a file to be accepted as a file upload. Default is 250M.
struts.multipart.parser − The library used to upload the multipart form. By default is jakarta.
struts.multipart.saveDir − The location to store the temporary file. By default is javax.servlet.context.tempdir.
26.What are the Struts2 error message keys that can come during file uploading process?
The fileUplaod interceptor uses several default error message keys −
struts.messages.error.uploading − A general error that occurs when the file could not be uploaded.
struts.messages.error.file.too.large − Occurs when the uploaded file is too large as specified by maximumSize.
struts.messages.error.content.type.not.allowed − Occurs when the uploaded file does not match the expected content types specified.
27.How to override the default error message that can come during file uploading process?
You can override the text of these messages in WebContent/WEB-INF/classes/messages.properties resource files.
28.What is Structs 2 validation framework?
At Struts’s core, we have the validation framework that assists the application to run the rules to perform validation before the action method is executed. Action class should extend the ActionSupport class, in order to get the validate method executed.
29.How Struts 2 validation works?
When the user presses the submit button, Struts 2 will automatically execute the validate method and if any of the if statements listed inside the method are true, Struts 2 will call its addFieldError method. If any errors have been added then Struts 2 will not proceed to call the execute method. Rather the Struts 2 framework will return input as the result of calling the action.
So when validation fails and Struts 2 returns input, the Struts 2 framework will redisplay the view file. Since we used Struts 2 form tags, Struts 2 will automatically add the error messages just above the form filed.
These error messages are the ones we specified in the addFieldError method call. The addFieldError method takes two arguments. The first is the form field name to which the error applies and the second is the error message to display above that form field.
30.What is XML Based Validation in struts2?
The second method of doing validation is by placing an xml file next to the action class. Struts2 XML based validation provides more options of validation like email validation, integer range validation, form validation field, expression validation, regex validation, required validation, requiredstring validation, stringlength validation and etc.