CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Our Services
Get 9,000 Interview Questions & Answers in an eBook.




Get it now !!
Send your Resume to 6000 Companies
Struts Interview Questions & Answers - Learning Mode
COOLINTERVIEW.COM 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

1 2 3 4 5 6 Next

Sort By : Latest First | Oldest First | By Rating

Struts Interview Questions & Answers - Learning Mode
Try Struts Interview Questions & Answers - Exam Mode
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 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.

Eg:

<tiles-definitions>
<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" />
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..
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: 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: 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: Explain about token feature in Struts?

Answer: <b>Use the Action Token methods to prevent duplicate submits</b>:
<P>
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.
<ul>
<li> saveToken(request)
<li> on the ret 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: 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 ( pakumar@omniglobeinternational.com )



Source: CoolInterview.com
Question: Who will run the execute method in struts?

Answer: Request Processor. Source: CoolInterview.com
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: 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

Example :

<!-- Date Sources -->
<data-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">
</<data-sources>
<!-- Form Beans -->
< Source: CoolInterview.com
Question: What are the various Struts tag libraries?

Answer: The Struts distribution includes four tag libraries for the JSP framework (in struts-config.xml) :

* Bean tag library [ struts-bean.tld ] : Contains tags for accessing JavaBeans and their properties. Developers can also define new beans and set properties
* HTML tag library [ struts-html.tld ] : Contains tags to output standard HTML, including forms, textfields, checkboxes, radio buttons
* Logic tag library [ struts-logic.tld ] : Contains tags for generating conditional 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: 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: 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
Source: CoolInterview.com
Question: How you will handle errors and exceptions using Struts?

Answer: Struts exception handling can be done by two ways:

1. Declarative (using struts features via struts-config.xml)

<global-exceptions>
<exception
type="hansen.playground.MyException2"
key ="errors.exception2"
path="/error.jsp"/>
</global-exceptions>


This makes coding in the Action class very simple


Since the execute method declares throws Exception we don't need a try-catch block.


Struts saves the exc Source: CoolInterview.com
Question: What is the difference between ActionErrors and ActionMessages?

Answer: There is no differnece between these two classes.All the behavior of ActionErrors was copied into ActionMessages and vice versa. This was done in the attempt to clearly signal that these classes can be used to pass any kind of messages from the controller to the view -- where as errors being only one kind of message.

The difference between saveErrors(...) and saveMessages(...) is simply the attribute name under which the ActionMessages object is stored, providing two convenient default lo 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 Action Class. What are the methods in Action class



Answer: An Action is an adapter between the contents of an incoming HTTP request and the corresponding business logic that should be executed to process this request. The controller (RequestProcessor) will select an appropriate Action for each request, create an instance (if necessary), and call the execute method.

Actions must be programmed in a thread-safe manner, because the controller will share the same instance for multiple simultaneous requests. This means you should design with the foll Source: CoolInterview.com

1 2 3 4 5 6 Next



India News Network
Latest 20 Questions
Payment of time- barred debt is: (a) Valid (b) Void (c) Illegal (d) Voidable
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
Cache = 0.375 Seconds