Struts2 Interview Questions And Answers

Struts2 interview questions and answers on advance and basic Struts2 with example so this page for both freshers and experienced condidate. Fill the form below we will send the all interview questions on Struts2 also add your Questions if any you have to ask and for apply in Struts2 Tutorials and Training course just send a mail on in detail about your self.

Top Struts2 interview questions and answers for freshers and experienced

What is Struts2 ?

Answer :

Questions : 1 :: What is Struts2 ?

Apache Struts 2 is an elegant, extensible framework for creating enterprise-ready Java web applications. The framework is designed to streamline the full development cycle, from building, to...View answers

Questions : 2 :: What kind of MVC is Struts 2?

Struts 2 is a front controller MVC which is to say that the user interacts with the controller before the UI. You send a request and a controller or Action responds with the mapped UI components....View answers

Questions : 3 :: How does one create an Action in Struts 2?

Struts 2 uses reflection to find an appropriate method which by default is the execute method. Best practice however should be to implement the Action interface or extend...View answers

Questions : 4 :: In struts.xml, what does the attribute "method" stands for in the "action" tag?

The method attribute tells the name of the method invoked after setting the properties of the action. This attribute can hold the name of the method or the index of the result mapping. For example:...View answers

Questions : 5 :: Are Interceptors thread safe?

No, and they are supposed to be stateless according to the documentation.

Questions : 6 :: Are Actions thread safe?

Struts 2 actions are but old Struts 1 actions were not. New struts actions are created per each request in Struts 2.

Questions : 7 :: How are Interceptors and Servlet Filters different?

1. Filters are part of the Servlet API, Interceptors are Struts 2. 2. The Interceptor stack fires on requests in a configured package while filters only apply to their mapped URLs. 3. Interceptors...View answers

Questions : 8 :: How can duplicate form submission be handled in Struts 2?

The problem of duplicate form submission arises when a user clicks the Submit button more than once before the response is sent back. This may result in inconsistent transactions and must be avoided....View answers

Questions : 9 :: Whats the difference between the default namespace and the root namespace?

The default namespace is "" - an empty string. The default namespace is used as a "catch-all" namespace. If an action configuration is not found in a specified namespace, the default namespace is...View answers

Questions : 10 :: What are Pull and Push MVC architecture and which architecture does Struts2 follow?

In Push-MVC the model data is given to the view layer by putting it in scoped variables like request or session. Typical example is Spring MVC and Struts1. Pull-MVC supposedly puts the model data in...View answers

Questions : 11 :: What is interceptor in Struts2?

Interceptors are the backbone of Struts2 Framework. Struts2 interceptors are responsible for most of the processing done by the framework, such as passing request params to action classes, making...View answers

Questions : 12 :: Which design pattern is implemented by Struts2 interceptors?

Struts2 interceptors are based on intercepting filters design pattern. The invocation of interceptors in interceptor stack closely resembles Chain of Responsibility design pattern.

Questions : 13 :: What are different ways to create Action classes in Struts2?

Struts2 provide different ways to create action classes. By implementing Action interface Using Struts2 @Action annotation By extending ActionSupport class Any normal java class with execute()...View answers

Questions : 14 :: Does Struts2 action and interceptors are thread safe?

Struts2 Action classes are thread safe because an object is instantiated for every request to handle it. Struts2 interceptors are singleton classes and a new thread is created to handle the request,...View answers

Questions : 15 :: Which class is the Front Controller in Struts2? is the Front Controller class in Struts2 and every request processing starts from this class. Earlier versions of Struts2 uses...View answers

Questions : 16 :: What are the benefits of Interceptors in Struts2?

Some of the benefits of interceptors are: Interceptor plays a crucial role in achieving high level of separation of concerns. Struts2 interceptors are configurable, we can configure it for any...View answers

Questions : 17 :: What is ValueStack and OGNL?

ValueStack is the storage area where the application data is stored by Struts2 for processing the client requests. The data is stored in ActionContext objects that use ThreadLocal to have values...View answers

Questions : 18 :: Name some useful annotations introduced in Struts2?

Some of the important annotations introduced in Struts2 are: @Action to create action class @Actions to configure single class for multiple actions @Namespace and @Namespaces for creating...View answers

Questions : 19 :: Provide some important Struts2 constants that you have used?

Some of the Struts2 constants that I have used are: struts.devMode to run our application in development mode. This mode does reload properties files and provides extra logging and debugging...View answers

Questions : 20 :: 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.

Questions : 21 :: 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...View answers

Questions : 22 :: 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...View answers

Questions : 23 :: 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...View answers

Questions : 24 :: 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...View answers

Questions : 25 :: 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...View answers

Questions : 26 :: 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...View answers

Questions : 27 :: 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.

Questions : 28 :: What is Custom Type Converter in Struts2?

Struts2 support OGNL expression language and it performs two important tasks in Struts 2 – data transfer and type conversion. OGNL is flexible and we can easily extend it to create our own...View answers

Questions : 29 :: How can we write our own interceptor and map it for action?

We can implement com.opensymphony.xwork2.interceptor.Interceptor interface to create our own interceptor. Once the interceptor class is ready, we need to define that in struts.xml package where we...View answers

Questions : 30 :: What is life cycle of an interceptor?

Interceptor interface defines three methods – init(), destroy() and intercept(). init and destroy are the life cycle methods of an interceptor. Interceptors are Singleton classes and Struts2...View answers

Questions : 31 :: What is an interceptor stack?

An interceptor stack helps us to group together multiple interceptors in a package for further use. struts-default package creates some of the mostly used interceptor stack – basicStack and...View answers

Questions : 32 :: What is struts-default package and what are it's benefits?

struts-default is an abstract package that defines all the Struts2 interceptors and commonly used interceptor stack. It is advisable to extend this package while configuring our application package...View answers

Questions : 33 :: What is the default location of result pages and how can we change it?

By default Struts2 looks for result pages in {WEBAPP-ROOT}/{Namespace}/ directory but sometimes we want to keep result pages in another location, we can provide struts.convention.result.path constant...View answers

Questions : 34 :: How can we upload files in Struts2 application?

File Upload is one of the common task in a web application. Thats why Struts2 provides built in support for file upload through FileUploadInterceptor. This interceptor is configured in struts-default...View answers

Questions : 35 :: What are best practices to follow while developing Struts2 application?

Some of the best practices while developing Struts2 application are: Always try to extend struts-default package while creating your package to avoid code redundancy in configuring...View answers

Questions : 36 :: What is Action Class?

An Action class in the struts application is used to handle the request. It acts as interface or communication medium between the HTTP request coming to it and business logic used to develop the...View answers

Questions : 37 :: What is Struts Validator Framework?

Struts Validator Framework enables us to validate the data of both client side and server side. When some data validation is not present in the Validator framework, then programmer can generate...View answers

Questions : 38 :: What is the need of Struts?

We need Struts in Java because of following reasons: Helps in creation and maintenance of the application. Make use of Model View Controller (MVC) architecture. Where Model is referring to...View answers

Questions : 39 :: What are the classes used in Struts?

Struts Framework consists of following classes: Action Servlets: used to control the response for each incoming request. Action Class: used to handle the request. Action Form: it is java bean,...View answers

Questions : 40 :: How exceptions are handled in Struts application?

Exceptions are handled in struts by using any one of the following two ways: Programmatically handling: In this exception are handled by using try and catch block in program. Using this programmer...View answers

Questions : 41 :: What is MVC?

Model View Controller (MVC) is a design pattern used to perform changes in the application. Model: Model is referring to business or database. It stores the state of the application. Model has no...View answers

Questions : 42 :: Describe Validate() and reset() methods.

Validate() Method: this method is used to validate the properties after they are explored by the application. Validate method is Called before FormBean is handed to Action. This method returns a...View answers

Questions : 43 :: What design patterns are used in Struts?

There are following types of design patterns are used in Struts: Service to Worker Dispatcher View Composite View (Struts Tiles) Front Controller View Helper Synchronizer...View answers

Questions : 44 :: What is the difference between session scope and request scope when saving FormBean?

The difference between session scope and request scope when saving FormBean are following: In Request Scope, values of FormBean are available to current request but in Session Scope, values of...View answers

Questions : 45 :: What is the different actions available in Struts?

The different kinds of actions in Struts are: ForwardAction IncludeAction DispatchAction LookupDispatchAction SwitchAction

Questions : 46 :: What is DispatchAction?

The DispatchAction enable the programmer to combine together related function or class. Using Dispatch Action programmer can combine the user related action into a single UserAction. like add...View answers

Questions : 47 :: How to use DispatchAction?

We can use the Dispatch Action we executing following steps: Create a class that extends DispatchAction. In a new class, add a method: method has the same signature as the execute() method of an...View answers

Questions : 48 :: What is the difference between ForwardAction and IncludeAction?

The difference between ForwardAction and InculdeAction are: IncludeAction is used when any other action is going to intake that action whereas ForwardAction is used move the request from one...View answers

Questions : 49 :: .What is difference between LookupDispatchAction and DispatchAction?

The difference between LookupDispatchAction and DispatchAction are given below: LookupDispatchAction is the subclass of the DispatchAction Actual method that gets called in LookupDispatchAction...View answers

Questions : 50 :: What is LookupDispatchAction?

The LookupDispatchAction class is a subclass of DispatchAction The LookupDispatchAction is used to call the actual method. For using LookupDispatchAction, first we should generate a subclass with...View answers

Questions : 51 :: What is the use of ForwardAction?

The ForwardAction is used when we want to combine Struts with existing application. Used when we want to transfer the control form JSP to local server. Used to integrate with struts in order to...View answers

Questions : 52 :: What is IncludeAction?

The IncludeAction is used to integrate the one action file in another action file. It is same as ForwardAction but the only difference is that the resource is present in HTTP response. Is used to...View answers

Questions : 53 :: What are the various Struts tag libraries?

The various Struts tag libraries are: HTML Tags: used to create the struts input forms and GUI of web page. Bean Tags: used to access bean and their properties. Logic Tags: used to perform the...View answers

Questions : 54 :: What is the life cycle of ActionForm?

The lifecycle of ActionForm is as follows: Retrieve or Create Form Bean associated with Action "Store" FormBean in appropriate scope (request or session) Reset the properties of the...View answers

Questions : 55 :: What are the loop holes of Struts

The drawbacks of Struts are following: Absence of backward flow mechanism. Only one single controller Servlets is used. Bigger learning curve Worst documentation No exception present in this...View answers

Questions : 56 :: Difference between Html tags and Struts specific HTML Tags?

Difference between HTML tag and Struts specific HTLM tags are: HTML tags are static in nature but Struts specific HTML tags are dynamic in nature. HTML tags are not User Defined whereas Struts...View answers

Questions : 57 :: How to display validation errors on JSP page?

Validation error: Validation error are those error which arises when user or client enters the invalid format data into the form. For this validation of data struts enables the programmer with the...View answers

Questions : 58 :: How to use forward action to restrict a strut application to MVC?

We can use the ForwarAction to restrict the Struts application to Model View Controller by following coding: <global-forwards> <statements> <forward name="CitizenDetailsPage"...View answers

Questions : 59 :: What is ActionMapping?

In action mapping is the mapping of the action performed by the user or client on the application. -We specify the action class for a specific user’s action. Like we provide the path or URL...View answers

Questions : 60 :: How to combine the Struts with Velocity Template?

We can combine Struts and Velocity template by performing following steps: 1. Set classpath to Velocity JARs 2. Make web.xml file to identify the Velocity servlet. 3. Select Velocity toolbox.xml in...View answers

Questions : 61 :: In how many ways duplicate form submission can occurs?

The submission form can be duplicated by the any of the following ways: Using refresh button. By clicking submit button more than once before the server sent back the response. By clicking back...View answers

Questions : 62 :: What is the difference between Struts 1 and struts2?

The difference between struts1 and struts2 are below: Struts1 uses ActionServlet as Controller where as Struts2 uses Filter as a controller. Struts1 uses the ActionForm for mapping the JSP forms...View answers

Questions : 63 :: What are the steps used to setup dispatch action?

To setup the dispatch action the following steps are used: Create a subclass for DispatchAction. Create method for logical action and their related actions. Request Parameter is created for each...View answers

Questions : 64 :: What is difference between Interceptors and Filters?

The difference between Interceptors and filter are below: Filters are based on Servlet Specification whereas Interceptors are based on Struts2. Filters are executed only when patter matches...View answers

Questions : 65 :: What are the Custom tags?

Custom Tags are User Defined Tags, which means that user can create those tags depending upon their need in the application. When a JSP page consisting of user- defined or custom tag is translated...View answers

Questions : 66 :: What is the difference between empty default namespace and root namespace?

The difference between the empty default namespace and root name space are: When namespace attribute is not defined then it is referred to as Empty Default Namespace whereas when name space...View answers

Questions : 67 :: What is the difference between RequestAware and ServletRequestAware interface?

The difference between RequestAware and ServletRequestAware are: RequestAware enables programmer with the attributes in the Servlet Request as a map whereas ServletRequestAware enables programmer...View answers

Questions : 68 :: What are inner class and anonymous class?

Inner class: classes that are defined within other classes. The nesting is a relationship performed between two different classes. An inner class can access private members and data. Inner...View answers

Questions : 69 :: What is struts.devMode?

The struts.devMode is used to make sure that framework is running in development mode or production mode by setting true or false. struts.devMode is set to false in production phase to reduce impact...View answers

Questions : 70 :: What are action errors?

Action error: when user or client submits the incorrect or invalid data in the application, then these errors are known as Action error. Action errors are generated by the clients. Action error...View answers
More Question

Ask your interview questions on Struts2

Write Your comment or Questions if you want the answers on Struts2 from Struts2 Experts
Name* :
Email Id* :
Mob no* :
Comment* :

--------- Tutorials ---