- Front Controller pattern
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." [Alur, "Core J2EE Patterns", p. 166.]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 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:
* Spring, a Java MVC framework
*Zend Framework Notes
References
* cite book
last = Alur
first = Deepak
authorlink =
coauthors = John Crup, Dan Malks
title = Core J2EE Patterns, Best Practices and Design Strategies, 2nd Ed.
publisher = Sun Microsystems Press
date = 2003
location =
pages = 650pp
url =
doi =
id =
isbn = 0-13-142246-4* cite book
last = Fowler
first = Martin
authorlink = Martin Fowler
coauthors =
title = Patterns of Enterprise Application Architecture
publisher =
date =
location =
pages = 560pp
url = http://www.martinfowler.com/books.html#eaa
doi =
id =
isbn = 978-0321127426* Fowler, Martin. [http://www.martinfowler.com/eaaCatalog/frontController.html "Front Controller"] . Accessed
Feb 2 2008 .
Wikimedia Foundation. 2010.