Two Laptop Bag*
The moose likes Struts and the fly likes Dispatcher vs web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Dispatcher vs web.xml" Watch "Dispatcher vs web.xml" New topic
Author

Dispatcher vs web.xml

J.H.B. Oosterlaar
Ranch Hand

Joined: Sep 12, 2002
Posts: 41
Hi,
We are developing a small request handler, that logs request information based on its origin. Our first idea is to write a dispatcher servlet that finds out the type of request and passes that request to the specific action. This finding out is based on the url. For example:
http://www.site.com/Image.regist will be mapped to the ImageRegister object, etc.
Another way is to write servlets for each type of action. In the example we could write a ImageRegisterServlet and still invoke it the same way, by adding the servletmapping to the web.xml file.
Jakarta Struts uses a dispatcher because the actions itself are variable. We have a static number of actions, so mapping in the web.xml file is possible.
In our situation, what is preferrable: writing a dispatcher (which implements some basic business logic), or use the web.xml to map each servlet. These servlet could extend a basic servlet that does that business logic?
Thanks for replies.
Ruud Steeghs
Ranch Hand

Joined: Jul 09, 2001
Posts: 56
What's the reason for not using Struts?
It's very flexible and it's a framework which is going to save you quite some work.
I think it preferrable over both your solutions.
For example: in both your solutions you are going to spend some time programming the logic for performing the business operations either successfully or not, and passing the request to the appropriate jsp page.
Cheers,
Ruud.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Dispatcher vs web.xml