|Struts Interview Questions & Answers - Learning Mode|
J2EE INTERVIEW QUESTIONS
STRUTS INTERVIEW QUESTIONS QUESTIONS & ANSWERS - LEARNING MODE
Struts Interview Questions & Answers - Learning Mode
Apache Struts is an open-source web application framework for developing Java EE web applications. It uses and extends the Java Servlet API to encourage developers to adopt a model-view-controller (MVC) architecture.
|Try Struts Interview Questions & Answers - Exam Mode|
|Struts Interview Questions & Answers - Learning Mode|
|Try Struts Interview Questions & Answers - Exam Mode|
Question: What is the purpose of tiles-def.xml file, resourcebundle.properties file, validation.xml file?
Answer: 1. tiles-def.xml
tiles-def.xml is used as a configuration file for an appliction during tiles development
You can define the layout / header / footer / body content for your View.
<definition name="siteLayoutDef" path="/layout/thbiSiteLayout.jsp">
<put name="title" value="Title of the page" />
<put name="header" value="/include/thbiheader.jsp" />
<put name="footer" value="/include/thbifooter.jsp" />
Question: What is struts flow? Explain in detail
Answer: Struts is a open source implementation of MVC design pattern to develop large scale web applications.Struts framework makes it easier to design realible,scalable web applications in java.Struts is not only thread safe but also thread dependent.It instantiates each action once and allows others to be threaded through the original object.Struts reduces the for redundant jsp's.ActionForm stratagy reduces the need of sub class hierarchy.
Struts is a light weight package.It consists of 5 Source: CoolInterview.com
Question: What we will define in Struts-config.xml file. And explain their purpose?
Answer: In struts-config.xml we define Date Sources / Form Beans / Global Exceptions / Global Forwards / Action Mappings / Message Resources / Plug-ins
<!-- Date Sources -->
<data-source autoCommit="false" description="First Database Config" driverClass=" org.gjt.mm.mysql.Driver" maxCount="4" minCount="2" password="admin" url="jdbc: mysql://localhost/ARTICLEDB" user="admin">
<!-- Form Beans -->
< Source: CoolInterview.com
Question: What is DispatchAction?
Answer: DispatchAction is specialized child of Struts Action class. It combines or group the methods that can further access the bussiness logic at a single place. The method can be anyone from CRUD [Create,Retrieve,Update or Delete] or it can be security check one like autheniticate user etc.
This class apart from having thread-safe execute method also can have user-defined methods.
In struts-config.xml files following changes are required for Dispatch action to work:
<act Source: CoolInterview.com
Question: Who will run the execute method in struts?
Answer: Request Processor. Source: CoolInterview.com
Question: How to call ejb from Struts?
Answer: We can call EJB from struts by using the service locator design patteren or by Using initial context with create home object and getting return remote referenc object.
Submitted by Pankaj Kumar ( firstname.lastname@example.org )
Question: Explain about token feature in Struts?
Answer: <b>Use the Action Token methods to prevent duplicate submits</b>:
There are methods built into the Struts action to generate one-use tokens. A token is placed in the session when a form is populated and also into the HTML form as a hidden property. When the form is returned, the token is validated. If validation fails, then the form has already been submitted, and the user can be apprised.
<li> on the ret Source: CoolInterview.com
Question: What is the difference between ActionForm and DynaActionForm
Answer: # The DynaActionForm bloats up the Struts config file with the xml based definition. This gets annoying as the Struts Config file grow larger.
# The DynaActionForm is not strongly typed as the ActionForm. This means there is no compile time checking for the form fields. Detecting them at runtime is painful and makes you go through redeployment.
# ActionForm can be cleanly organized in packages as against the flat organization in the Struts Config file.
# ActionForm were desi Source: CoolInterview.com
Question: Explain Struts navigation flow?
Answer: Struts Navigation flow.
1) A request is made from previously displayed view.
2) The request reaches the ActionServlet which acts as the controller .The ActionServlet Looksup the requested URI in an XML file (Struts-Config.xml) and determines the name of the Action class that has to perform the requested business logic.
3)The Action Class performs its logic on the Model Components associated with the Application.
4) Once The Action has been completed its processing it returns th Source: CoolInterview.com
Question: What is the difference between a normal servlet and action servlet?
Answer: Both a normal servlet and action sevlet are same, which extend HttpServlet and implement the servlet lifecycle methods..
Question: What is the difference between Struts 1.0 and Struts 1.1
Answer: The new features added to Struts 1.1 are 1. RequestProcessor class 2. Method perform() replaced by execute() in Struts base Action Class 3. Changes to web.xml and struts-config.xml4.Declarative exception handling5.Dynamic ActionForms6.Plug-ins7.Multiple Application Modules8.Nested Tags9.The Struts Validator10.Change to the ORO package11.Change to Commons logging12.Removal of Admin actions13. Deprecation of the GenericDataSource Source: CoolInterview.com
Question: In struts, if any changes are made to before the request reaches to actionservlet, where you do the changes?
Answer: In struts the first to recieve the request is Actionservlet. So, there is no chance for you to make changes before Source: CoolInterview.com
Question: In struts why we use jsp as presentation layer? can we use servlet as presentation layer?
Answer: 1. We can seperate the business logic from presentation logic
2.It facilitates to write the java code inside a html environment
if we use servlets then we need to write the html tags inside out.write() number of times. it is not possible in all cases and it combines the businesslogic and presentation logic which reduces security
Question: What are the drawbacks of Struts
Answer: In struts , their is no facility of backward flow.
Suppose we are in page 1 and when we submit it calls action mapping page2.Their may be lot of variable stored in session , which is available to page2.Now we wish to go page1 from page 2, for this we have to call the action mapping of page1. But struts flow is always in forward direction. So when we call page 1, values stored in session never get reversed.So it reduces the performance.
To resolve this problem of struts, Their is a Source: CoolInterview.com
Question: Explain about Struts ?
Answer: Apache is used for developing Java web applications. It has garnished huge popularity because open source web framework. It encourages developers to implement MVC architecture. It became a top priority project within the Apache Foundation and it is now known as Jakarta Struts. Source: CoolInterview.com
Question: Explain the necessity of empty tag?
Answer: When the requested variable does not contain any information, (null or empty) then this tag is used to know the contents present in the other body parts of the tag. If the tag is nested then it is advisable to use this tag as it may contain a bit of information. Source: CoolInterview.com
Question: What is the difference between bean:write and bean:message
Answer: In Jakarta Struts - you may be knowing that - both are custom tags defined in HTML Tag library.
Both are used for accessing Java beans.
Bean:Message - is to access a java bean that will display a message such as " For more details on the product displayed in this web site please contact a phone number 12345.."
Bean: write - is to display a data from the model; example "Number of People visited this site is: 1234"
Bean does not directly write. the Tag is used to take Source: CoolInterview.com
Question: What is the difference between Struts 1.0 and Struts 1.1?
Answer: The new features added to Struts 1.1 are
1. RequestProcessor class
2. Method perform() replaced by execute() in Struts base Action Class
3. Changes to web.xml and struts-config.xml
4.Declarative exception handling
7.Multiple Application Modules
9.The Struts Validator
10.Change to the ORO package
11.Change to Commons logging
12.Removal of Admin actions
13. Deprecation of the GenericDataSource.
Submitt Source: CoolInterview.com
Question: How do i configure web.xml using with struts.
Answer: Sturts framework use 2 types of configuration files: web.xml & struts-cofig.xmlConfiguaring web.xml for Struts is:2- steps are involved in this process1)Add .tld file in the web.xml. Eg: if you are using html file add strtus-html.tld in /WEB-INF/struts-html.tld/WEB-INF/struts-html.tld2) Configuring Action Servlet which wil recieve all incoming requests.Use Servet element to configure the instance of servlet & later can be mapped in the servlet mapping using some name the class name some name *.d Source: CoolInterview.com
Question: What about JSTL and JavaServer Faces ?
Answer: JSTL, the JavaServer Standard Tag Library, is a set of JSP tags that are designed to make it easier to develop Web applications. JavaServer Faces (JSF) is a specification for a new technology that promises to make it easier to write MVC applications, both for the Web and for the desktop.
The inventor of Struts, Craig McClanahan, is the specification co-lead for JavaServer Faces (JSR 127), and architect of the reference implemenation as well as Java Studio Creator. Both JSTL and JSF are comple Source: CoolInterview.com
India News Network
Latest 20 Questions
Payment of time- barred debt is:
Consideration is defined in the Indian Contract Act,1872 in: (a) Section 2(f) (b) Section 2(e) (c) Section 2(g) (d) Section 2(d)
Which of the following is not an exception to the rule, "No consideration, No contract": (a) Natural love and affection (b) Compensation for involuntary services (c) Completed gift (d) Agency
Consideration must move at the desire of: (a) The promisor (b) The promisee (c) The promisor or any other party (d) Both the promisor and the promisee
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal