Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

05 November 2007

Struts- MVC Architecture Contd...............

Let us try to understand Struts framework in some what more detailed manner......


Step Wise Flow of Control Of Struts

1.First we see a Jsp/HTML page on our Web Browser,if it is this page is retrieved from Web.xml
File.
2.Their is a Web.xml file which is Deployment Descriptor.

Roles Of Deployment Descriptor
  • Locates the First JSP page which would pop up in the Web based Project.
  • It is responsible for mapping of JSP page to its equivalent servlet.
  • Information to Library file is also contained in this file.
  • Formating of address which is to be displayed as URL.It represent all those pages with .do extension which have more than one forward page, where a decision has to be taken which page needs to be displayed on the basis of the user input.
3.Now after Web.xml file which next happens to be the heart of a Strut application is
Struts-Config.xml.

Role Of Struts-Config.xml
  • Action Mapping-:Now Action Mapping means to map each JSP page to its corresponding Servlet, Bean class,Action class and Business Logic Class .
  • Local Forwards-: This tab contains Information about the all the possible JSP pages to which a given JSP page can redirect to on the basis of user input.
  • Local Exceptions-:This defines the error handling mechanism.
4.Before the data from form is stored in Bean class of the corresponding page Validator Framework comes into picture. This validator framework is responsible for server side validation of inputs.To introduce constraints on any field of form you will need to make changes in 2 files one is Valitator.xml and Validator-rules.xml.

Validator.xml describes the logic which needs to be check for each and every field of JSP form whereas Validator-rules.xml describes the location of the logic and gives name to each logic which is then used in Validator.xml. After data has been checked for compliance to standard rules values are stored in bean which are then further used as described in previous post of mine.




Sphere: Related Content

26 October 2007

Struts- MVC Architecture Contd...............

This figure depicts an M-V-C Architecture.
M-Model
V-View
C-Controller

Model- That part of application which deals with database creation, insertion and retrieval of data is know as Model. Programming of database can be done through JDBC, hibernate and other database languages.


View - These are the dynamic or static web pages which can be created using JSP , JSF etc. These are similar to HTML tags in many ways only additional thing which they enable is the support for JAVA which makes them far more powerful than HTML tags.

Controller-This is that part of your application which process each request sent by web browser and decides upon which next page should be displayed.

Form Bean- These are those classes which store values of parameters filled in a given form. Each JSP page has a form bean where the value of all parameters or fields is set or reset.

Now i will try to explain the flow of control from the above picture step by step

  1. Web browser sends a request to server.
  2. Servelet take this request and first stores all the parameter(Fields) value which where filled in the form to the corresponding Form bean of the page.
  3. Then Servlet goes to Action class which is the controller of your application. This class helps determining the next JSP page on the basics of Field or parameter values which it retrieve from bean.
  4. Action class interacts with Business Logic for retrieving desired data from database.
  5. Then data is sent to the next JSP page selected by the Action Class.
  6. JSP is then sent to Web Browser.



Sphere: Related Content

Struts- MVC Architecture

Its my first time on this blog that i am going to try to take up some technology. These days i am busy with final year seminar which is Struts an MVC architecture, so now i have decided to take up this topic in my blog.

Struts

Apache Struts is an open-source framework that is used for developing Java web application.Originally developed by the programmer and author Craig R. McClanahan this was later taken over by the Apache Software Foundation in 2002. Struts have provided an excellent framework for developing application easily by organizing JSP and Servlet basically based on HTML formats and Java code.

Why do we need Struts?

Java technologies give developers a serious boost when creating and maintaining applications to meet the demands of today's public Web sites and enterprise intranets. Struts combines Java Servlets, Java ServerPages, custom tags, and message resources into a unified framework.

How does Struts work?

Struts combines Java Servlets, Java ServerPages.

  • Java Servlets are designed to handle requests made by Web browsers.
  • Java ServerPages are designed to create dynamic Web pages.
Struts uses a special Servlet to route requests from Web browsers to the appropriate ServerPage.

Why is it called Struts?

It's a reference to struts in the architectural sense, a reminder of the nearly invisible pieces that hold up buildings, houses, and bridges.




Sphere: Related Content