The Configuration File in Context


Now that you've seen the format of the configuration file, it's worth talking about how the file interrelates all the other elements of Struts.

For example, you can begin by looking at it from the perspective of the JSP page. When a page uses an <html:form> tag with an action attribute, the attribute is looked up in the configuration file to discover the corresponding <action> tag. This tag in turn defines the form class, which allows the JSP page to make use of the <html:text> and other form input tags, and the action class, which is used to process the results after validation.

In addition, the action might need to communicate with a database, which could have been configured using a data source directive in the configuration file. When the action finishes processing, it uses an ActionForward to pass control to a new JSP page (or Action ), which is configured using local and global forward tags in the configuration file.

Centralizing all the relationships between forms, actions, and JSP pages in one file makes it easy to change functionality or move a file without impacting a large number of source files. For example, if you decide to move all the error pages into a common errors subdirectory, you need to change the URI in only one location ”where the forward was defined in the configuration file.



Struts Kick Start
Struts Kick Start
ISBN: 0672324725
EAN: 2147483647
Year: 2002
Pages: 177

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net