This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Servlets and the fly likes Handlers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Handlers" Watch "Handlers" New topic


RJ Joshi

Joined: Dec 30, 2002
Posts: 12
Explain the function of handlers in a web application
Roger Graff
Ranch Hand

Joined: May 29, 2001
Posts: 112
"Handlers" are also called "Action" classes. They are used in web applications that employ a "model 2" (also called model-view-controller, MVC) design pattern.
A "model 2" web app has what's called a controller servlet whose sole responsibilty to receive http requests from web browsers, determine what the end-user wants to do, determine which class is designed to execute the user's request, and calls a method on that class to handle that action.
My impression is that the term "Handler" is what developers called these classes in the pre-internet client-server days. They are now called "Actions".
Simon Brown has an excellent chapter in his book "Servlets 2.3" about designing web applications and you can download it for free on his web site
RJ Joshi

Joined: Dec 30, 2002
Posts: 12
Thanks ..I would like to know how the handler class and dispatcher class interact ?
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12682
Basically, the dispatcher sets up the request with any information the handler will need and then (typically) uses a RequestDispatcher to forward the request to the handler. Then the dispatcher is no longer involved, the handler completes the response.

Java Resources at
I agree. Here's the link:
subject: Handlers
Similar Threads
Message handlers
Dynamic AJAX control
hard stop window close
classic tag handlers questions
select: onchange or onclick?