ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Java J2EE  >>  Java Related  >>  Struts
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
Hi Friends,  why struts introduced in to web application.
Plz dont send any links . Need main reason for implementing
struts.  Thanks Prakash
 Question Submitted By :: Prakash
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Hi Friends, why struts introduced in to web application. Plz dont send any links . Need main reason for implementing struts. Thanks Prakash
Answer
# 1
Before writing the answer i am assuming that u have idea 
about MVC Architecture.

When u r writing the programm using servlet and jsp,every 
time u have to write ur own Controoler which is responsible 
for handling the request and response.

 Writing the Controller is a very tedious task and u might 
suffer from so many ecceptions even errors....which is 
really very diffcult to handle.

So  manage to Controller Apache introduce the Struts.
Struts is also called controller........
In struts the Action servlet and Request Processor is 
responsible to handle the Request and Response.
HOW.............

The basic purpose of the Java Servlets in struts is to 
handle requests made by the client or by web browsers. In 
struts JavaServerPages (JSP) are used to design the dynamic 
web pages. In struts, servlets helps to route request which 
has been made by the web browsers to the appropriate 
ServerPage. The use of servlet as a router helps to make 
the web applications easier to design, create, and 
maintain. Struts is purely based on the Model- View- 
Contoller (MVC) design pattern. It is one of the best and 
most well developed design patterns in use. By using the 
MVC architecture we break the processing in three sections 
named Model, the View, and the Controller. Below we are 
describing the working of struts.

As we all are well aware of the fact that each application 
we develop has a deployment descriptor i.e. WEB-
INF/web.xml. This is the file which the container reads. 
This file has all the configuration information which we 
have defined for our web application. The configuration 
information includes the index file, the default welcome 
page, the mapping of our servlets including path and the 
extension name, any init parameters, information related to 
the context elements. 

In the file WEB-INF/web.xml of struts application we need 
to configure the Struts ActionServlet which handles all the 
request made by the web browsers to a given mapping.  
ActionServlet is the central component of the Struts 
controller. This servlet extends the HttpServlet. This 
servlet basically performs two important things. First is : 
When the container gets start, it reads the Struts 
Configuration files and loads it into memory in the init() 
method. You will know more about the Struts Configuration 
files below. Second point is: It intercepts the HTTP 
request in the doGet() and doPost() method and handles it 
appropriately.
   
In struts application we have another xml file which is a 
Struts configuration file named as struts.config.xml. The 
name of this file can be changed. The name of the struts 
configuration file can be configured in the web.xml file. 
This file is placed under the WEB-INF directory of the web 
application.  It is an XML document that describes all or 
part of Struts application. This file has all the 
information about many types of Struts resources and 
configures their interaction.  This file is used to 
associate paths with the controller components of your 
application., known as Action classes like <action path 
="/login" type = "LoginAction">.  This tag tells the Struts 
ActionServlet that whenever the incoming request is 
http://myhost/myapp/login.do, then it must invoke the 
controller component LoginAction. Above, you can see that 
we have written .do in the URL. This mapping is done to 
tell the web application that whenever a request is 
received with the .do extension then it should be appended 
to the URL.  
   
For each action we also have to configure Struts with the 
names of the resulting pages that will be shown as a result 
of that action. In our application there can be more than 
one view which depends on the result of an action. One can 
be for a success and the other for the failure. If the 
result action is "success" then the action tells the 
ActionServlet that the action has been successfully 
accomplished or vice- versa.  The struts knows how  to 
forward the specific page to the concerned destination. The 
model which we want to use is entirely to you, the model is 
called from within the controller components. 
   
Action can also get associate with a JavaBean in our Struts 
configuration file. Java bean is nothing but a class having 
getter and setter methods that can be used to communicate 
between the view and the controller layer. These java beans 
are validated by invoking the validate() method on the 
ActionForm by the help of the Struts system. The client 
sends the request by the normal form submission by using 
Get or Post method, and the Struts system updates that data 
in the Bean before calling the controller components.
   
The view we use in the struts can be either Jsp page, 
Velocity templates, XSLT pages etc. In struts there are set 
of JSP tags which has been bundled with the struts 
distribution, but it is not mandatory to use only Jsp tags, 
even plain HTML files can be used within our Struts 
application but the disadvantage of using the html is that 
it can't take the full advantage of all the dynamic 
features provided in the struts framework. 
The framework includes a set of custom tag libraries that 
facilitate in creating the user interfaces that can 
interact gracefully with ActionForm beans. The struts Jsp 
taglibs has a number of generic and struts specific tags 
tags which helps you to use dynamic data in your view. 
These tags helps us to interact with your controller 
without writing much java code inside your jsp. These tags 
are used create forms, internally forward to other pages by 
interacting with the bean and helps us to invoke other 
actions of the web application. 
There are many tags provided to you in the struts 
frameworks which helps you in sending error messages, 
internationalization etc. 
   
Note: The points we have described above will be in effect 
if and only if when the ActionServlet is handling the 
request. When the request is submitted to the container 
which call the ActionServlet, make sure that the extension 
of the file which we want to access should have the 
extension .do.


for futhere u may call me...

Thanks and Regards
Anjani Kumar Jha
09623154095
CDAC
 
Is This Answer Correct ?    5 Yes 0 No
Anjani Kumar Jha
 
  Re: Hi Friends, why struts introduced in to web application. Plz dont send any links . Need main reason for implementing struts. Thanks Prakash
Answer
# 2
there are two main reason one is expressive and other one 
is reusabilty
if u found any problem for that we don need to invent new 
solution for that just will have to pattern thats it and u 
can make very expressive ur applicaion by struts



Ramesh bajantri
 
Is This Answer Correct ?    0 Yes 1 No
Ramesh
 
 
 

 
 
 
Other Struts Interview Questions
 
  Question Asked @ Answers
 
what is mean by custom tag? Wipro4
is it possible to see actionservlet in my system. if yes how  5
How display data base errors on web console by using the Struts Framework?  1
what is the disadvantages of using DynaActionForm in struts framework? HCL4
when connecting with the database,if database server is down,ho can we handle this exception in struts,how can we send error message to the user? Wipro4
What is MVC? Infosys5
how to write my own Action servlet by extending pre-defined Action servlet in struts config. Sony2
How to explain struts work flow TCS5
What is difference between perform() used in struts1.0 and execute() used in 1.1 ? Infotech2
How many types of action clases are there in stuts and their uses? TCS7
session menagement in servlets explaion briefly?  1
where you will implement the tiles in struts? Wipro2
What is Hibernate?  3
Is it possible to create mulitple instance of one Action Class in struts? Satyam9
struts comes under which layer of three tire architecture in real time projects plz i need explaination? Infinite-Computer-Solutions6
How is the Struts framworl related to MVC2? Wipro1
tell me struts flow ? Fidelity4
Difference between JSF Framework and Struts Framework. Accenture8
What is the use of ActionErrors in Struts? HCL1
Even though Servlets and JSP are web based concepts .wht is the use of using Struts using then TCS7
 
For more Struts Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com