Struts Interview Questions and Answers
Ques 76. Resources under WEB-INF
According to the Servlet specification, resources (e.g. JSP files) stored under WEB-INF are protected and cannot be accessed directly by the browsers. One design idiom for Struts 1.0 is to put all the JSP files under WEB-INF and front them by Actions so that clients cannot illegally access the JSPs. With the introduction of sub-application prefixes in Struts 1.1, mapping resources under WEB-INF gets complicated. Extra configuration steps utilizing the pagePattern and forwardPattern attributes of the element in struts-config.xml is required to inform Struts to construct the paths correctly. More specifically, you need to set these attributes to the pattern "/WEB-INF/$A$P".
Ques 77. What is the Jakarta Struts Framework?Ans.
Jakarta Struts is an open source implementation of MVC
(Model-View-Controller) pattern for the development of web based applications.
Jakarta Struts is a robust architecture and can be used for the development of applications of any size.
The ?Struts framework? makes it easier to design scalable, reliable Web applications.
Ques 78. What is an ActionServlet?Ans. The class org.apache.struts.action.ActionServlet is called the ActionServlet.
In the Jakarta Struts Framework this class plays the role of controller.
All the requests to the server go through the ?Controller?.
The ?Controller? is responsible for handling all the requests.
Ques 79. How can one make any ?Message Resources? definitions file available to the ?Struts Framework? environment?Ans. Message Resources definitions file are simple .properties files and
these files contain the messages that can be used in the struts project.
?Message Resources? definition files can be added to the struts-config.xml file
through <message-resources /> tag. Example:
<message-resources parameter="MessageResources" />
Ques 80. What is an Action Class?Ans. The ?Action Class? is part of the ?Model? and is a wrapper around the business logic.
The purpose of the ?Action Class? is to translate the HttpServletRequest to the business logic.
To use the ?Action?, we need to subclass and overwrite the execute() method.
All the database and business processing is done in the ?Action? class.
It is advisable to perform all the database related work in the ?Action? class.
The ActionServlet (command) passes the parameterized class to ActionForm using the execute() method.
The return type of the execute method is ActionForward which is used by the Struts Framework to forward the request to the file according to the value of the returned ActionForward object.
Most helpful rated by users: