Explain Struts Framework flow? and How JSP file can be processed?

Questions by raghavendhark

Showing Answers 1 - 10 of 10 Answers

kavithareddy

  • Mar 18th, 2006
 

what is struts and its frame work, and also what serialisation and how many ways of serialisation is possible, and another one is what is markup interface. and what is list and linkedflist in java

  Was this answer useful?  Yes

sathish.vj

  • Mar 21st, 2006
 

markup interface is like serialisation public interface kavithareddy{ } public class sathish impliments kavithareddy{ public static void main (String []ghfgcf){ } now sathish class instance will serialised (can reback the state of the object) . Struts is a MVC frame workV=view(presentation logic) ===jspC=Controler(select and forward to appropirate bean )===servletsM=model(bussinus logic)====bean

  Was this answer useful?  Yes

Madhav Reddy

  • Mar 22nd, 2006
 

Struts frame work uses front controller design pattern for its centralized flow. First it matches the incoming path(*.do) with appropriate action in actionMapping of struts-config.xml. From this  appropriate ActionForm is taken from fromBeans Tag and populates that frombean with incoming data and validate method is called for any validations required.If no validation errors are there then execute() method of Action class is called.Then the results are presented to the View. 

  Was this answer useful?  Yes

MadhavReddy

  • Mar 22nd, 2006
 

Hi Kavitha,

   Struts follows MVC architecture and has many design patterns which it uses inside(ex Frontcontroller,Value Objects).First it maps incoming path with path attribute of ActionMapping in struts-config.xml file and finds appropriate Action class for the request and maps the name attribute of ActionMapping with that of FormBeans tag. Then finds appropriate ActionForm for the request. Then it calls Validate() method of ActionForm if required.If there are no validation errors then Action class is called.Here business Logic starts and results are returned to the controller which presents in the appropriate View.

 Acatually a lot of things happen behind the scene which will complicate the matter.

  Was this answer useful?  Yes

Raveen Kumar G

  • Mar 23rd, 2006
 

MVC Model 2 Architecture is Struts.

1. Whenever a request comes to controller ActionServlet is Invoked which looks for ActioMapping in struts-config.xml

2. Action Servlet looks for existence of form bean corresponds to input request.

3. If not exist then instatinate the correpsonding ActionForm

4. ActionServlet Call the execute method of the corresponding Action Class

5. Which return ActionForward object with lookup value.

6. Action Servlet then do ActionMapping the forward to the Corresponding View according to the lookup value of ActionForward Class.

7. View Responds it to Client.

This is MVC 2 Architecture. This is Servlet Centric.

  Was this answer useful?  Yes

Serialisation is basically mant for sustaining objects state by making it persistent. Serialisation is an empty interafce which is supposed to be implement by the class whose object are required to maintain their state. We can have customized serialisation by using Externilazable class. We ned to provide implmentation to Two of it's methods readExtern() and writeEntern.

  Was this answer useful?  Yes

giri

  • Apr 11th, 2006
 

  i) All requests are passed through a controller servlet, known as Action-servlet.

This is achieved by suitable 'url-mapping' in web.xml file.We have been doing  'URL-pattern' in Tomcat4,when using servlets.

And in j2ee webserver like Tomcat, this facilitates 'centralized-declarative change  management', by editing the concerned XML files, without touching the source or class files of the servlets.or Struts Actions...

  ii) All data submitted by user are sent to corresponding ActionForm.There are many actionforms but only one ActionServlet(because, it is the controller).

  iii) The ActionServlet, examines the source of request and   extracts the data from specified actionform and sends it to a specified instance of Action class.(as specified in struts-config.xml).

   iv) The action object carries out the business logic either directly or through helper classes , creates an instance of valuebean, populates this bean with data and sends the bean to the View JSP.( an instance of ActionForward).

 v) The important and distinctive feature of this arrangement is that the entire thing is done by 'Declarative-Management'.(and hence ActionMapping)

  vi) Sometimes, the data submitted has to be validated and error messages , generated. (ActionErrors).

 vii) We use tags in input side and also for output view.(The input form also belongs to 'view' category in MVC.)( Struts-tags)

 viii)  The details about the ActionServlet and other servlets if any ,in our application are given in web.xml

 ix) Details about various action classes,forms, action-forwards etc are given in struts-config.xml

Struts frame work uses front controller design pattern for its centralized flow. First it matches the incoming path(*.do) with appropriate action in actionMapping of struts-config.xml. From this appropriate ActionForm is taken from fromBeans Tag and populates that frombean with incoming data and validate method is called for any validations required.If no validation errors are there then execute() method of Action class is called.Then the results are presented to the View.

  Was this answer useful?  Yes

Struts Frame work 

This is what i understud by reading books and also tested successfully.

When a request is made to the Struts application, the first servlet Invoked is ActionServlet, which contains implementation for doGet(),doPost() methods.

Both these methods imvokes process() method which initialises the struts executions.  This process method invokes processPreproces() method of RequestProcessor class. This method returns boolean value. If it returns false then request professing will be terminated and error page will be desplayed.

else (in case of true) the request processor object will read the path associated with request Object and reads the struts-config.xml files to find the corresponding action element having same path as in the request.

 If it finds the action element then it reads the name of the action element whose value is the name of the form-bean, Then it populates the request object holded values to that FormBean class.

Then if the validate attribute of the action element is set to true then it also invokes the validate method on the FormBean.

If the validation goes fine then it will dispatch the exeuction process to Action class mapped as a value to type attribute of action element.

Once the request is processed i.e after compeletion of execution fo execute() method the response will be received by RequestProsessor class object i.e the ActionFroward class Object .

Based on this object the response page to  be displayed will be read from the forward sub element of the action element. and That  will be displayed at client side.

This is the internal execution of the complete struts application.

Any comments, suggetions accepted

pradeep

  • May 25th, 2006
 

Hi to all

As Madhav specified 

(Struts follows MVC architecture and has many design patterns which it uses inside(ex Frontcontroller,Value Objects). )

what are the other design patterns which it uses inside and can it be brief

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions