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 access of multiple threads to shared resources. Withou

All difference Question in java(common difference) (Collections)

1)Difference Between Interfaces And Abstract class? All the methods declared in the Interface are Abstract,where as abstract class must have atleast one abstract method and others may be concrete. In abstract class keyword abstract must be used for method, where as in Interface we need not use the keyword for methods. Abstract class must have Sub class, where as Interface can’t have sub classes.  An abstract class can extend only one class, where as an Interface can extend more than one. 2)Difference between Arrays and Vectors?             Because Vectors are dynamically-allocated, they offer a relatively memory-efficient way of handling lists whose size could change drastically. Arrays are fixed in size and it's wastage of memory problem. A Vector might be a good choice for such an arrangement. Moreover, Vectors have some useful member functions that make coding simpler. While in array is the bad choice of the arrangement and the code become more complex. Vecto

Decode of the image file from hibernate and struts

Create a java file for the decoding the image Image.java package com.img.action; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import javax.imageio.ImageIO; import javax.servlet.ServletRequest; import javax.servlet.http.HttpServletRequest; import org.apache.struts2.ServletActionContext; import com.img.dao.ConnectionDAO; import com.img.pojo.Film_TablePojo; import com.img.pojo.imagePojo; import com.opensymphony.xwork2.ActionSupport; public class Show extends ActionSupport { List<Object> values = new ArrayList<Object>();  public List<Object> getValues() { return values; } public void setValues(List<Object> values) { this.values = values; } /*HttpServletRequest request;     public void setServletRequest(HttpServletRequest