Skip to main content

Struts 2 Interview question for experienced candiate



1) Explain Struts?

           Struts is open source software used to develop java based web page. 
Struts takes the help of Model View Controller (MVC) architecture. Where Model is referring to business or database, View is referring to the Page Design Code, and Controller is referring to navigational code.

Struts uses Jakarta Packages, Java Servlets, JavaBeans, ResourceBundles, and XML.

2)What is the need of the Struts ?

  • Helps in creation and maintenance of the application. 
  • Make use of Model View Controller (MVC) architecture. Where Model is referring to business or database, View is referring to the Page Design Code, and Controller is referring to navigational code. 
  • Enables developer to make use of Jakarta Packages(Struts 2.0), Java Servlets, JavaBeans, ResourceBundles, and XML.

3)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 application. Action class consists of RequestProcessor which act as controller. 



4)How Exception are Handled in struts 2.0?

  • Programmatically handling: In this exception are handled by using try and catch block in program. Using this programmer can define how to handle the situation when exception arises. 
  • Declarative handling: In this exception handling is done by using the XML file. Programmer defines the exception handling logic in the XML file. 

5)What are the classes used in the struts2.0?


  1.            Action Class
  2.           Action Servlet
  3.           Action form
  4.           Action mapping

  1.           Action forward

6)What is MVC?

    Mvc- Model view Controller:

     
Model: Model is referring to business or database. It stores the state of the application. Model has no knowledge of the View and Controller components. It is used for the representing business logic.

• View: View is referring to the Page Design Code. It is responsible for the showing the result of the user’s query. View modifies itself when any changes in the model happen.  It is the combination of an model and controller.

• Controller: Controller is referring to navigational code. Controller will chose the best action for each incoming request, generate the instance of that action and execute that action. It will control all the all action class and then pass the action into the view page.

7) what designed pattern are used in struts2.0?

  •     Dispatcher view
  •     Fornt controller
  •     view helper
  •    Synchroinzed token
8)What is ActionServlet?

ActionServlet is a simple servlet which is the backbone of all Struts applications.

 It is the main Controller component that handles client requests and determines which Action will process each received request. It serves as an Action factory – creating specific Action classes based on user’s request.

9)what is the role of the Action servlet?

*Process user Requests.
*Determine what the user are trying to achieve according to the user request.
*It is the responsible for the intalize and clean up the process.

10)what are the different action are available in the strust2.0?

  1. Forward action
  2. Include action
  3. Dispatch action
  4. Lookup action
  5. Switch action.


10)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 user, delete user and update user.
  • DispatchAction execute the action based on the parameter value it receives from the user.
  • It is the mechanism for grouping the set of the related function into the single action.


11)How to use DispatchAction?

  • Create a class that extends DispatchAction.
  • In a new class, add a method: method has the same signature as the execute() method of an Action class.
  • Do not override execute() method.
  • Add an entry to struts-config.xml





Comments

Popular posts from this blog

Commonly asked Top 26 Java Interview Questions

1.what is a transient variable? A transient variable is a variable that may not be serialized. If you don't want to serialize any objects then we have to use Transient Keyword. 2. Why do threads block on I/O? Threads block on i/o (that enters the waiting state) so that other threads may execute while the i/o Operation is performed. So your blocked thread of execution blocks only that: the thread of execution. 3. How are Observer and Observable used? Objects that subclass the Observable class maintain a list of observers. When an Observable object is updated it invokes the update() method of each of its observers to notify the observers that it has changed state. The Observer interface is implemented by objects that observe Observable objects(refer 1.4). 4. What is synchronization and why is it important?                      With respect to multithreading, synchronization is the capability to control the...

Top Most Important Multithreading interview question and answers

1) What is Thread in java? Threads consumes CPU in best possible manner, hence enables multi processing. Multi threading reduces idle time of CPU which improves performance of application. Thread are light weight process. It belongs to java.lang package. It can run mutiple threads simutaneously .                                                               2) How to implements threads in java?         By   implementing java.lang.Runnable interface or extending java.lang.Thread class and then extending run method.   Thread creation by implementing java.lang.Runnable interface.      And then create Thread object by calling constructor and passing reference of Runnable interface i.e. runnable object          Thread threa...

Program for a Non-Repeating Characters

1)Write a program for non repeating Characters?   class Char               {                    public static void  main(String arsg[])                     {                            public static char FirstNonRepatingChar(String word)                               {                                 Set<characters>nonrepeating = new HashSet<>();                                   List<characters>nonrepeating = new ArrayList<>();                 ...