Front controller: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Add reference to coldfusion
add space
Line 1: Line 1:
The '''Front Controller Pattern''' is a software [[design pattern]] listed in several pattern catalogs. The pattern relates to the design of web applications. It "provides a centralized entry point for handling requests."<ref>Alur, ''Core J2EE Patterns'', p. 166.</ref>
The '''Front Controller Pattern''' is a software [[design pattern]] listed in several pattern catalogs. The pattern relates to the design of web applications. It "provides a centralized entry point for handling requests."<ref>Alur, ''Core J2EE Patterns'', p. 166.</ref>


The front controller may manifest as a script in a [[script language]] like PHP, ASP,CFML or JSP that is called on every request of a web session. This script, for example an ''index.php'', would handle all tasks that are common to the whole application or the framework around, like session handling, caching, input filtering. Depending on the given input it would then instantiate further objects and call methods to handle the particular task.
The front controller may manifest as a script in a [[script language]] like PHP, ASP, adCFML or JSP that is called on every request of a web session. This script, for example an ''index.php'', would handle all tasks that are common to the whole application or the framework around, like session handling, caching, input filtering. Depending on the given input it would then instantiate further objects and call methods to handle the particular task.


The alternative to a front controller would be individual scripts like ''login.php'' and ''order.php'' that would each include the code or objects that are common to all tasks. This would need a repetition of the inclusion code in each script but might also leave more room for specific needs of a script.
The alternative to a front controller would be individual scripts like ''login.php'' and ''order.php'' that would each include the code or objects that are common to all tasks. This would need a repetition of the inclusion code in each script but might also leave more room for specific needs of a script.

Revision as of 00:58, 3 October 2008

The Front Controller Pattern is a software design pattern listed in several pattern catalogs. The pattern relates to the design of web applications. It "provides a centralized entry point for handling requests."[1]

The front controller may manifest as a script in a script language like PHP, ASP, adCFML or JSP that is called on every request of a web session. This script, for example an index.php, would handle all tasks that are common to the whole application or the framework around, like session handling, caching, input filtering. Depending on the given input it would then instantiate further objects and call methods to handle the particular task.

The alternative to a front controller would be individual scripts like login.php and order.php that would each include the code or objects that are common to all tasks. This would need a repetition of the inclusion code in each script but might also leave more room for specific needs of a script.

Examples

Several web-tier application frameworks implement the Front Controller pattern, among them:

Notes

  1. ^ Alur, Core J2EE Patterns, p. 166.

References

  • Alur, Deepak (2003). Core J2EE Patterns, Best Practices and Design Strategies, 2nd Ed. Sun Microsystems Press. pp. 650pp. ISBN 0-13-142246-4. {{cite book}}: Unknown parameter |coauthors= ignored (|author= suggested) (help)