Struts2 Questions and Answers. This section provides a great collection of Struts2 Multiple Choice Questions (MCQs) on a single page along with their correct answers and explanation. If you select the right option, it turns green; else red. If you are preparing to appear for a Java and Struts2 Framework related certification exam. Spring Multiple Choice Questions And Answers. Engineering Multiple choice pdf for Freshers and Latest Machine Design. Spring, Struts, Unix, SOAP, Rest, Design. AP Physics Simple Harmonic Motion Multiple Choice Questions is a set of objective The velocity of a spring-mass system at.
Struts2 is one of the famous framework for developing web application in java. Recently I have wrote a lot of and in this post, I am listing down some of the important Struts2 interview questions with answers to help you in interview. Struts2 Interview Questions. Struts2 Interview Questions and Answers. What is Struts2? Apache Struts2 is an open source framework to build web applications in Java. Struts2 is based on OpenSymphony WebWork framework.
It’s highly improved from Struts1 and that makes it more flexible, easy to use and extend. The core components of Struts2 are Action, Interceptors and Result pages. Struts2 provides many ways to create Action classes and configure them via struts.xml or through annotations.
We can create our own interceptors for common tasks. Struts2 comes with a lot of tags and uses OGNL expression language. We can create our own type converters to render result pages. Result pages can be JSPs and FreeMarker templates. What are the differences between Struts1 and Struts2 or how Struts2 is better than Struts1?
![Pdf Pdf](http://civilengineeringmcq.com/wp-content/uploads/pdf-light-viewer/2197/page-00001.jpg)
Struts2 is designed to overcome the shortcomings of Struts1 and to make it more flexible, extendable. Some of the noticeable differences are. Copy. What is the use of namespace in action mapping in Struts2?
Struts2 namespace configuration allows us to create modules easily. We can use namespace to separate our action classes based on their functionality, for example admin, user, customer etc. Which interceptor is responsible for mapping request parameters to action class Java Bean properties? Com.opensymphony.xwork2.interceptor.ParametersInterceptor interceptor is responsible for mapping request parameters to the Action class java bean properties. This interceptor is configured in struts-default package with name “params”. This interceptor is part of basicStack and defaultStack interceptors stack. Which interceptor is responsible for i18n support?
Com.opensymphony.xwork2.interceptor.I18nInterceptor interceptor is responsible for i18n support in Struts2 applications. This interceptor is configured in struts-default package with name “i18n” and it’s part of i18nStack and defaultStack. What is the difference in using Action interface and ActionSupport class for our action classes, which one you would prefer? We can implement Action interface to create our action classes. This interface has a single method execute that we need to implement.
The only benefit of using this interface is that it contains some constants that we can use for result pages, these constants are SUCCESS, ERROR, NONE, INPUT and LOGIN. ActionSupport class is the default implementation of Action interface and it also implements interfaces related to Validation and i18n support. ActionSupport class implements Action, Validateable, ValidationAware, TextProvider and LocaleProvider interfaces. We can override validate method of ActionSupport class to include field level validation login in our action classes. Depending on the requirements, we can use any of the approaches to create struts 2 action classes, my favorite is ActionSupport class because it helps in writing validation and i18n logic easily in action classes. How can we get Servlet API Request, Response, HttpSession etc Objects in action classes? Struts2 action classes doesn’t provide direct access to Servlet API components such as Request, Response and Session.
However sometimes we need these access in action classes such as checking HTTP method or setting cookies in response. Thats why Struts2 API provides a bunch of.Aware interfaces that we can implement to access these objects. Struts2 API uses dependency injection to inject Servlet API components in action classes. Some of the important Aware interfaces are SessionAware, ApplicationAware, ServletRequestAware and ServletResponseAware. You can read more about them in How to get tutorial. What is the use of execAndWait interceptor?
Struts2 provides execAndWait interceptor for long running action classes. We can use this interceptor to return an intermediate response page to the client and once the processing is finished, final response is returned to the client. This interceptor is defined in the struts-default package and implementation is present in ExecuteAndWaitInterceptor class.
Check out to learn more about this interceptor and how to use it. What is the use of token interceptor in Struts2? One of the major problems with web applications is the double form submission. If not taken care, double form submission could result in charging double amount to customer or updating database values twice. We can use token interceptor to solve the double form submission problem.
This interceptor is defined in struts-default package but it’s not part of any interceptor stack, so we need to include it manually in our action classes. Read more at example. How can we integrate log4j in Struts2 application?
Struts2 provides easy integration of log4j API for logging purpose, all we need to have is log4j configuration file in the WEB-INF/classes directory. You can check out the sample project at. What are different Struts2 tags? How can we use them? Struts2 provides a lot of custom tags that we can use in result pages to create views for client request.
These tags are broadly divided into three categories- Data tags, Control tags and UI tags. We can use these tags by adding these in JSP pages using taglib directive. Copy /exception.jsp /runtimeexception.jsp /error.jsp /error.jsp Read more at. Thats all for the Struts2 interview question and answers, if you come across any important question that I have missed, please let me know through comments.
Struts Interview Questions There is given frequently asked struts interview questions and answers that has been asked in many companies. Let's see the list of top Struts2 interview questions. 1) What is Struts? Struts is a framework for developing MVC-based framework. Struts2 is the combination of Webwork and struts1 frameworks.
2) What is the difference between struts1 and struts2? Struts1 Struts2 1) Action class is not POJO.
You need to inherit abstract class. Action class is POJO. You don't need to inherit any class or implement any interface. 2) Front controller is ActionServlet. Front Controller is StrutsPrepareAndExecuteFilter.
3) It uses the concept of RequestProcessor class while processing request. It uses the concept of Interceptors while processing the request. 4) It has only JSP for the view component. It has JSP, Freemarker, Valocity etc. For the view component.
5) Configuration file name can be anyname.xml and placed inside WEB-INF directory. Configuration file must be struts.xml and placed inside classes directory. 6) Action and Model are separate.
Action and Model are combined within action class. 3) What are the features of Struts?. Configuration MVC components. POJO based action. AJAX Support. Various Tag Support. Various Result Types.
Integration Support 4) What is MVC? MVC is a design pattern. MVC stands for Model, View and Controller. Model represents data, view represents presentation and controller acts as an interface between model and view. 5) What is interceptor? Interceptor is an object i.e. Invoked at preprocessing and postprocessing of a request.
It is pluggable. 6) What are the life cycle methods of interceptor?. public void init. public void intercept(ActionInvocation ai). public void destroy 7) What is ValueStack?
ValueStack is a stack that contains application specific object such as action and other model. 8) What is ActionContext? ActionContext is a container in which action is executed. It is unique per thread. 9) What is ActionInvocation? ActionInvocation is responsible to invoke action.
It holds action and interceptor objects. 10) What is OGNL? OGNL is an expression language of struts2. It stands for Object Graph Navigation Language. 11) What are the 5 constants of Action interface?.
SUCCESS. ERROR.
INPUT. LOGIN.
NONE 12) What does params interceptor? The params (also known as parameters) interceptor sets all parameters on the ValueStack. 13) What does execAndWait interceptor?
The execAndWait (also known as ExecuteAndWait) interceptor is used to display intermediate or wait result. 14) What does modelDriven interceptor? The modelDriven interceptor makes other model as the default object of ValueStack. By default, action is the default object of ValueStack.
15) What does validation interceptor? The validation interceptor performs validation checks and adds field-level and action-level error messages. 16) What are the bundled validators?. requiredstring. stringlength.
email. date. int. double. url. regex 17) What is the difference between plain-validator and field-validator? In plain-validator one validator can be applied to many fields.
In field-validator many validators can be applied to single field. 18) What is the use of jsonValidation? The jsonValidation interceptor is used to perform asynchronous validation. It works with validation and workflow interceptors. 19) What are the aware interfaces in struts2? Aware interfaces are used to store information in request, session, application and response objects.
![Questions Questions](/uploads/1/2/5/3/125357472/333763439.png)
The 4 aware interfaces are given below:. ServletRequestAware.
ServletResponseAware. SessionAware.
ServletContextAware 20) What does i18n interceptor? The i18n interceptor is used to provide multi lingual support for struts application.