This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Servlets and the fly likes Using Servlet as a Dispatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Using Servlet as a Dispatcher" Watch "Using Servlet as a Dispatcher" New topic

Using Servlet as a Dispatcher

Mark Mescher
Ranch Hand

Joined: Oct 25, 2004
Posts: 34
Hi out there,
I'm using three Servlets in my webapp as Dispatcher. On each call these Servlets are getting a parameter which describes what the Servlet will have to do.

Till now the called methods are private Methods of the Servlets. Normally they call some methods of some sessionbeans and than do something with the returned data.
The problem is that the servlet gets longer and longer and that these methods arent good reusable from other servlets. So I want to move this methods to some workerclasses.
Now I'm not sure what is the best design for these workerclasses. Normally I would make the methods static in these workerclasses. But I dont know if this solution works well in a Servlet / Sessionbean - Environment.
What do you think of this?? Are there any Design-Patterns for this?


Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 62139

Research the Front Controller pattern.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Using Servlet as a Dispatcher