File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Dispatcher vs web.xml" Watch "Dispatcher vs web.xml" New topic

Dispatcher vs web.xml

J.H.B. Oosterlaar
Ranch Hand

Joined: Sep 12, 2002
Posts: 41
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: 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.
I agree. Here's the link:
subject: Dispatcher vs web.xml
It's not a secret anymore!