GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  J2EE  >  Core Java
Go To First  |  Previous Question  |  Next Question 
 Core Java  |  Question 49 of 492    Print  
When you use a struts framework, where would you place your business logic

  
Total Answers and Comments: 10 Last Update: July 16, 2008   
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: aniruthmp
 
Struts forms MVC 2 architecture.. struts-config.xml forms the "Controller". Action Class SHOULD NOT have Business logic. The reason is, Action classes are not instantiated by the user/developer. It is automatically instantiated by the Controller. Always there will be only 1 INSTANCE of the action class (you can verify this by havin a Class variable and try incrementing the same by various requests). So, from action class instantiate a new Java class for each request in which business logic should be present. 
Also, Action class is not the Model class. Please correct yourself.

Above answer was rated as good by the following members:
Debananadajena
June 29, 2005 07:05:04   #1  
preeti        

RE: When you use a struts framework, where would you place your business logic
Business Logics are placed in the action class
 
Is this answer useful? Yes | No
September 12, 2005 06:38:19   #2  
D.S.Reddy        

To Overcome the disadvantages of Model1 architecture
We know how servlets and JSP's applications will be . They are all Model1 arcitectures. where we cant get the MVC (M2c) model architecture .So, we use this structs framework. And in this we can write the Business logic in Action class which is also called as Model part. And we write Presentation Logic in View Part of the architecture. And the Controller part acts as the controller and gives the mappings between the Model Part and the VIew parts of the application
 
Is this answer useful? Yes | No
April 13, 2007 03:48:31   #3  
bhore.vijay        

RE: When you use a struts framework, where would you ...
In Struts we should embed the business logic in Manager class.
 The Manager class should be instantiated in Action class.
 Using this object of Manager class a method from Manager class should be called.
e.g. LoginAction should call method from LoginManager using the instance loginManager.  All the Manager class should have the business logic in a method
e.g. method which returns boolean value 

     class LoginManager{

        public boolean authenticateUser(loginForm) {
        
              // business logic

        }
    }

 
Is this answer useful? Yes | No
May 19, 2007 13:42:32   #4  
reddyonlinenow        

RE: When you use a struts framework, where would you ...
Action class comes under controller it calls the model what ever we use such as business delegate or DAO.

Action class does not come under model.

 
Is this answer useful? Yes | No
June 21, 2007 20:40:10   #5  
Ram        

RE: When you use a struts framework, where would you ...
Action class forms part of the Model in struts... A class which has some logic need not always be a part of controller. The primary intention of the Action class is to Act on the Data that is submitted, and delegate it for further business processing, reiterating that it is in fact the Model component.

Even if you take in Swing, any Model class will not only have data for the corresponding component, but also have certain trigger methods such as fireXYZ(), which can be used to notify any intended recipient of change in data.

For instance, when a cell's data is changed, the controller needs to be notified by the model to render the cell appropriately. Hence, when the setValueAt() method is called, it is coded to invoke a trigger method fireTableCellUpdated, which in turn notifies any associated TableModelListener to take appropriate action.

 
Is this answer useful? Yes | No
July 31, 2007 01:23:35   #6  
sujatham Member Since: January 2006   Contribution: 142    

RE: When you use a struts framework, where would you ...
In  struts frame work, Business  logic  will be  placed  in the  Model  part.
 
Is this answer useful? Yes | No
December 05, 2007 22:11:45   #7  
aniruthmp Member Since: November 2007   Contribution: 1    

RE: When you use a struts framework, where would you place your business logic
Struts forms MVC 2 architecture.. struts-config.xml forms the "Controller". Action Class SHOULD NOT have Business logic. The reason is, Action classes are not instantiated by the user/developer. It is automatically instantiated by the Controller. Always there will be only 1 INSTANCE of the action class (you can verify this by havin a Class variable and try incrementing the same by various requests). So, from action class instantiate a new Java class for each request in which business logic should be present. 
Also, Action class is not the Model class. Please correct yourself.
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
December 11, 2007 23:45:27   #8  
kalpanachaitu Member Since: February 2007   Contribution: 3    

RE: When you use a struts framework, where would you place your business logic


            when we want to seperate the presentation logic(view ) and bussiness logic
then we go for Model view controller architecture, Struts a frame work which builds on that Arichetecture.so we use Struts.


           Bussiness logic is written in ActionServlet of struts frame work

 
Is this answer useful? Yes | No
December 17, 2007 23:43:22   #9  
shaik subhani Member Since: December 2007   Contribution: 11    

RE: When you use a struts framework, where would you place your business logic
When we want to develop complex applications , you can use struts framework.Strtus framework is based on MVC architecture. Actually we have model classes to develop businesslogic .you can access model classes from execute() method of Action class
 
Is this answer useful? Yes | No
July 16, 2008 10:45:19   #10  
Debananadajena Member Since: July 2008   Contribution: 2    

RE: When you use a struts framework, where would you place your business logic
When we are using struts the action class should not contain the business logic if we are adding in action class then it is not right because action class are instantiated by controller.So we can use other java classes like helper classes where we will keep our business logic and then we can instantiate them in action class.
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape