Category >
JAVA
|| Published on :
Thursday, May 14, 2015 || Views:
2959
||
Java Struts Interview Question for Java Developers Java Struts Interview Question for Java Developers
Java Struts Interview Question for Java Developers
Question 1.) How you will handle exceptions in Struts?
Ans: In Struts you can handle the exceptions in two ways:
a) Declarative Exception Handling: You can either define global exception handling tags in your struts-config.xml or define the exception handling tags within .. tag.
- Example:
- key="database.error.duplicate"
- path="/UserExists.jsp"
- type="mybank.account.DuplicateUserException"/>
b) Programmatic Exception Handling: Here you can use try{}catch{} block to handle the exception.
Question 2.) What are the core classes of the Struts Framework?
Ans: Core classes of Struts Framework are ActionForm, Action, ActionMapping, ActionForward, ActionServlet etc.
Question 3.) What are the components of Struts?
Ans: Struts is based on the MVC design pattern. Struts components can be categories into Model, View and Controller.
- Model: Components like business logic / business processes and data are the part of Model.
- View: JSP, HTML etc. are part of View
- Controller: Action Servlet of Struts is part of Controller components which works as front controller to handle all the requests.
Question 4.) How Struts relates to J2EE?
Ans: Struts framework is built on J2EE technologies (JSP, Servlet, Taglibs), but it is itself not part of the J2EE standard.
Question 5.) What are the various Struts tag libraries?
Ans: Struts is very rich framework and it provides very good and user friendly way to develop web application forms. Struts provide many tag libraries to ease the development of web applications. These tag libraries are:
- Bean tag library - Tags for accessing JavaBeans and their properties.
- HTML tag library - Tags to output standard HTML, including forms, text boxes, checkboxes, radio buttons etc..
- Logic tag library - Tags for generating conditional output, iteration capabilities and flow management
- Tiles or Template tag library - For the application using tiles
- Nested tag library - For using the nested beans in the application.
Question 6.) Is struts threadsafe?
Ans: Struts is not only thread-safe but thread-dependant.
Question 7.) How to communicate from struts to ejb?
Ans: In Struts architecture Action class contain execute() method, within execute() method it access database through jdbc or EJB. Then can call the reference of entity bean class by jndi call and easily fetch data from database.
Question 8.) Give the Details of XML files used in Validator Framework?
Ans: The Validator Framework uses two XML configuration files validator-rules.xml and validation.xml. The validator-rules.xml defines the standard validation routines, these are reusable and used in validation.xml. to define the form specific validations. The validation.xml defines the validations applied to a form bean.
Question 9.) What is ActionForm?
Ans: An ActionForm is a JavaBean that extends org.apache.struts.action.ActionForm. ActionForm maintains the session state for web application and the ActionForm object is automatically populated on the server side with data entered from a form on the client side.
Question 10.) What is ActionServlet?
Ans: 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.
Question 11.) What is Jakarta Struts Framework?
Ans: Jakarta Struts is open source implementation of MVC (Model-View-Controller) pattern for the development of web based applications. Jakarta Struts is robust architecture and can be used for the development of application of any size. Struts framework makes it much easier to design scalable, reliable Web applications with Java.