DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Join us today at 1 PM EST: "3-Step Approach to Comprehensive Runtime Application Security"
Save your seat

Understanding Front Controller Design Pattern

Sandeep Bhandari user avatar by
Sandeep Bhandari
·
May. 02, 11 · Tutorial
Like (0)
Save
Tweet
Share
53.79K Views

Join the DZone community and get the full member experience.

Join For Free

The front controller design pattern means that all requests that come for a resource in an application will be handled by a single handler and then dispatched to the appropriate handler for that type of request. The front controller may use other helpers to achieve the dispatching mechanism.

While reading the brief overview you may have thought about ActionServlet in Struts 1 or Dispatchers in Struts 2. Yes both of them are implementations of Front controller design pattern. But most of the developers that I have interacted to (specially the beginners) end their thought process of Front Controller at Struts only.

The Front Controller design pattern is applicable and useful for all kind of applications be it web or desktop applications and is not limited to any single programming language or framework. Before the rollout of MVC frameworks in the market, the design pattern was still in use.

The only downside was that not all application could make use of it because of the effort involved. Only the applications which had custom framework in place were using the design pattern.

So for example in case of a Java based web application, which is not using any MVC framework, all the requests would be mapped to a single servlet in web.xml file. This we know can be done by using the servlet mapping (same as we do for ActionServlet in case of Struts 1).

<web-app>    <servlet>        <servlet-name> FrontServlet</servlet-name>        <servlet-class> com.example.test.FrontServlet</servlet-class>    </servlet>    <servlet-mapping>        <servlet-name>FrontServlet<servlet-name>        <url-pattern>/*</url-pattern>    <servlet-mapping></servlet-mapping></servlet-name></servlet-name></servlet-mapping></web-app>

Once the request reached the FrontServlet, it uses some configuration files to decide the appropriate dispatcher for the request and thus forwards the request using forward mechanism.

From http://extreme-java.blogspot.com/2011/04/understanding-front-controller-design.html

 

Front controller Design

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Data Mesh vs. Data Fabric: A Tale of Two New Data Paradigms
  • Simulate Network Latency and Packet Drop In Linux
  • Playwright vs. Cypress: The King Is Dead, Long Live the King?
  • The Enterprise, the Database, the Problem, and the Solution

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: