• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

Struts Interview Questions Answers

Question - 21 : - What is Struts?

Answer - 21 : - Struts is a web page development framework and an open source software that helps developers build web applications quickly and easily. Struts combines Java Servlets, Java Server Pages, custom tags, and message resources into a unified framework. It is a cooperative, synergistic platform, suitable for development teams, independent developers, and everyone between.

Question - 22 : - Can you give me a simple example of using the requiredif Validator rule?

Answer - 22 : - First off, there's an even newer Validator rule called validwhen, which is almost certainly what you want to use, since it is much easier and more powerful. It will be available in the first release after 1.1 ships. The example shown below could be coded with validwhen as: <form name="medicalStatusForm"> <field property="pregnancyTest" depends="validwhen"> <arg0 key="medicalStatusForm.pregnancyTest.label"/> <var> <var-name>test</var-name> <var-value>((((sex == 'm') OR (sex == 'M')) AND (*this* == null)) OR (*this* != null))</test> </var> </field> Let's assume you have a medical information form with three fields, sex, pregnancyTest, and testResult. If sex is 'f' or 'F', pregnancyTest is required. If pregnancyTest is not blank, testResult is required. The entry in your validation.xml file would look like this: <form name="medicalStatusForm"> <field property="pregnancyTest" depends="requiredif"> <arg0 key="medicalStatusForm.pregnancyTest.label"/> <var> <var-name>field[0]</var-name> <var-value>sex</var-value> </var> <var> <var-name>fieldTest[0]</var-name> <var-value>EQUAL</var-value> </var> <var> <var-name>fieldValue[0]</var-name> <var-value>F</var-value> </var> <var> <var-name>field[1]</var-name> <var-value>sex</var-value> </var> <var> <var-name>fieldTest[1]</var-name> <var-value>EQUAL</var-value> </var> <var> <var-name>fieldValue[1]</var-name> <var-value>f</var-value> </var> <var> <var-name>fieldJoin</var-name> <var-value>OR</var-value> </var> </field> <field property="testResul

Question - 23 : - What configuration files are used in Struts?

Answer - 23 : - ApplicationResources.properties struts-config.xml These two files are used to bridge the gap between the Controller and the Model.

Question - 24 : - Do ActionForms have to be true JavaBeans?

Answer - 24 : - The utilities that Struts uses (Commons-BeanUtils since 1.1) require that ActionForm properties follow the JavaBean patterns for mutators and accessors (get*,set*,is*). Since Struts uses the Introspection API with the ActionForms, some containers may require that all the JavaBean patterns be followed, including declaring "implements Serializable" for each subclass. The safest thing is to review the JavaBean specification and follow all the prescribed patterns. Since Struts 1.1, you can also use DynaActionForms and mapped-backed forms, which are not true JavaBeans.

Question - 25 : - What is an “ActionForm”?

Answer - 25 : - An “ActionForm” is a JavaBean that extends org.apache.struts.action.ActionForm. ActionForm maintains the session state for web application and the “ActionForm” object is automatically populated on the server side with data entered from a form on the client side.  What is Struts Validator Framework? The “Struts Framework” provides the functionality to validate the form data. It can be used to validate the data in the user’s browser as well as on the server side. Struts Framework checks the JavaScript code and it can be used to validate the form data on the client browser. Server side validation of form data can be accomplished by subclassing your “form” Bean with DynaValidatorForm class. The “Validator” framework was developed by David Winterfeldt as a third-party “add-on” to Struts. Now the Validator framework is part of the “Jakarta Commons” project and it can be used with or without Struts. The Validator framework comes integrated with the Struts Framework and can be used without any making any additional settings. Describe the details of XML files used in the “Validator Framework”? The Validator Framework uses two XML configuration files 1) validator-rules.xml and 2) validation.xml. The validator-rules.xml defines the standard validation routines. These are reusable and used in validation.xml to define the form specific validations. The validation.xml defines the validations applied to a form bean.

Question - 26 : - What is an ActionServlet?

Answer - 26 : - The class org.apache.struts.action.ActionServlet is called the ActionServlet. In the Jakarta Struts Framework this class plays the role of controller. All the requests to the server go through the “Controller”. The “Controller” is responsible for handling all the requests.

Question - 27 : - Direct Requests to JSPs

Answer - 27 : - To take the full advantage of sub-application support, Struts 1.1 stipulates the requirement that all requests must flow through the controller servlet, i.e. the ActionServlet. Effectively, this means all JSPs must be fronted by Actions. Instead of allowing direct requests to any of the JSPs, all requests must go through an Action and let the Action forward to the appropriate JSP. This is perhaps the biggest impact of migration to Struts 1.1 if you have not followed this idiom in your applications. This restriction is required because without going through the ActionServlet, Struts navigation taglibs (e.g. <html:form> and <html:link>) used in the JSPs will not have the correct sub-app context to work with.

Question - 28 : - What is ActionForm?

Answer - 28 : - An ActionForm is a JavaBean that extends org.apache.struts.action.ActionForm. ActionForm maintains the session state for web application and the ActionForm object is automatically populated on the server side with data entered from a form on the client side.

Question - 29 : - What is the Jakarta Struts Framework?

Answer - 29 : - Jakarta Struts is an open source implementation of MVC (Model-View-Controller) pattern for the development of web based applications. Jakarta Struts is a robust architecture and can be used for the development of applications of any size.

Question - 30 : - Validator

Answer - 30 : - The Validator is not exactly a new feature. The Validator has been in the contrib package in the distribution since Struts 1.0.1. Since then, part of it has now been refactored and moved into the Jakarta-Commons subproject and renamed the Commons-Validator and the Struts specific portion is now called the Struts-Validator. However, since it is in the contrib package, people may overlook it and it is worthwhile to mention it here. The Validator provides an extensible framework to define validation rules to validate user inputs in forms. What is appealing in the Validator is that it generates both the server-side validation code and the client-side validation code (i.e. Javascript) from the same set of validation rules defined in an XML configuration file. The Validator performs the validation based on regular-expression pattern matching. While a handful of commonly used validators are shipped with the framework (e.g. date validator, range validator), you can always define your own ones to suit your need.

Computer Contributors

Rajeev Katiyar
Yes Baroda

Share your email for latest updates


Our partners