Front controller

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 24.4.60.104 (talk) at 00:58, 3 October 2008 (add space). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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)