2:03 am - Saturday January 21, 2017

Struts Interview Question

Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

Struts Interview Question


1.            What is Front Controller.

The Front Controller Pattern is a software design pattern listed in several pattern catalogs. The pattern relates to the design of web applications. It “provides a centralized entry point for handling requests.

2.            Explain struts Architecture.

Struts represents an implementation of MVC type 2 architecture. The most important components of Struts are the ActionServlet, Action, and ActionForm subclasses. ActionServlet represents the controller that intercepts the requests and forwards them for further processing based on the configuration file for the ActionForm and Action subclasses. ActionForm transfers data users entered to Action, which performs necessary operations using the Business Tier components of the application and finally forwards to a view.  The controller (ActionServlet) uses a configuration file (typically struts-config.xml) to load definitions of the Action subclasses that will be used to handle the requests.

3.            Explain MVC in Configuration File.

Model-View-Controller is the concept introduced by Smalltalk’s inventors to encapsulating some data together with its processing (the model) and isolate it from the manipulation (the controller) and presentation (the view) part that has to be done on a UserInterface.

A model :- is an object representing data e.g. a database table.

A view :- is some form of visualization of the state of the model.

A controller :- offers facilities to change the state of the model.

4.            Explain MVC in Java Files.

A model :- is an object representing data e.g. a database table.

A view :- is some form of visualization of the state of the model.

A controller :- offers facilities to change the state of the model.


5.            What is Action Form.

ActionForm will maintains the session state for web application and the its  object is automatically populated on the server side with data entered from a form on the client side.

6.            What is Action.

Action is part of the controller. The use  of this class is to translate the

HTTP Servlet Request to the business logic.

A Struts action is an instance of a subclass of an Action class, which implements a portion of a Web application and whose perform or execute method returns a forward.

7.            What is ActionServlet.

In struts technology this class plays the role of controller.controller is responsible for handling all the requests.

The class org.apache.struts.action.ActionServlet is the called the ActionServlet. In the the Jakarta Struts Framework this class plays the role of controller. All the requests to the server goes through the controller. Controller is responsible for handling all the requests.

Struts Flow start with ActionServlet then call to process() method of RequestProcessor.

Step 1. Load ActionServlet using load-on-startup and do the following tasks.

Any struts web application contain the ActionServlet configuration in web.xml file.

On load-on-startup the servlet container Instantiate the ActionServlet .

First Task by ActionServlet : The ActionServlet takes the Struts Config file name as an init-param.

At startup, in the init() method, the ActionServlet reads the Struts Config file and load into memory.

Second Task by ActionServlet : If the user types http://localhost:8080/app/submitForm.do in the browser URL bar, the URL will be intercepted and processed by the ActionServlet since the URL has a pattern *.do, with a suffix of “do”. Because servlet-mapping is





Third Task by ActionServlet : Then ActionServlet delegates the request handling to another class called RequestProcessor by invoking its process() method.


Step 2. ActionServlet calls process() method of RequestProcessor

8.            What is Global Forward.

In Struts, Global forwards are the action forwards which can be forwarded from any action. Consider, log out link, that will be present in all the page, so, u can’t write a forward in all the action mapping and check. so, struts is using global forwards, whatever forward declared in the global forwards can be visible to all action mapping. We will use global forwards in situtaions like logoff, error page.

9.            What is message resource.

Message Resources Definitions file are simple .properties files and these files contains the messages that can be used in the struts project. Message Resources Definitions files can be added to the struts-config.xml file through < message-resources / > tag.

Example: < message-resources parameter= MessageResources / >

Messsage resource defination files can available to the struts enviornment in two ways

1.By using web.xml as









<message-resource key="myResorce"

parameter="resource.Application" null="false">

10.          How to call EJB from struts.

Subclass your Action class and Override execute() method.

Then in body of execute() method do this:

1. Get Initial Context

2. Get home object using JNDI look up.

3 Create the bean and call teh business methods.

We can call EJB from struts by using the service locator design pattern or by Using initial context with create home object and getting return remote referenc object.

1 2 3 4



Filed in: Z-A Interview Questions

No comments yet.

Leave a Reply