What is Struts? Why you have used struts in your application or project.
What are the main classes which are used in struts application?
Struts
is nothing but open source framework mostly used for making web
application. framework comprises of JSP
,servlet ,custom tags message resources all in one bundle which makes
developer task very easy. Its is based on MVC pattern which is model
view Controller pattern.
Now why we use Struts?
So main reason is if we go with servlet all HTML code which is related
with design part mostly will come inside java code which makes code
unmaintainable and complex similarly if use JSP, all java code related
with business come inside design part which again make code complex,
that’s why MVC pattern come into existence and which separate the
business, design and controller and struts was made based upon this
pattern and easy to develop web application. The keyword to answer this
Struts interview questions is MVC design pattern, Front Controller Pattern and better flow management
What are the main classes which are used in struts application?
Main classes in Struts Framework are:
Action servlet: it’s a back-bone of web application it’s a controller class responsible for handling the entire request.
Action class: using Action classes all the business logic is developed us call model of the application also.
Action Form:
it’s a Java bean which represents our forms and associated with action
mapping. And it also maintains the session state its object is
automatically populated on the server side with data entered from a form
on the client side.
Action Mapping: using this class we do the mapping between object and Action.
ActionForward: this class in Struts is used to forward the result from controller to destination.
How exceptions are handled in Struts application?
There are two ways of handling exception in Struts:
Programmatically handling:
using try {} catch block in code where exception can come and flow of
code is also decided by programmer .its a normal java language concept.
Declarative handling: There are two ways again either we define <global-Exception> tag inside struts config.xml file
<exception
key="stockdataBase.error.invalidCurrencyType"
path="/AvailbleCurrency.jsp"
type="Stock.account.illegalCurrencyTypeException">
key="stockdataBase.error.invalidCurrencyType"
path="/AvailbleCurrency.jsp"
type="Stock.account.illegalCurrencyTypeException">
</exception>
Programmatic
and Declarative way is some time also asked as followup questions given
candidate’s response on knowledge on Struts.
Key: The key represent the key present in MessageResource.properties file to describe the exception.
Type: The class of the exception occurred.
Path: The page where the controls are to be followed is case exception occurred.
Path: The page where the controls are to be followed is case exception occurred.
No comments:
Post a Comment