I am doing a servlet project right now. On the server-side, I am trying to design a dispatchServlet which will receive the request from the user and dispatch this request to different servlets depending on some conditions.All the reponses will be handled in the latter servlets.So HttpServletResponse.sendRedirect() is not a good choice since all contents of the request will lose. Is RequestDispatcher the only choice? ( RequestDispatcher.forword()?) Any of your suggestion will be very appreciated.
Joined: Jul 06, 2000
My question to you is why do the "latter servlets" even have to be servlets? Why can't you make them regular Java Classes and have your dispatcher servlet create and call them directly? I have done this exact thing and in fact I am currently using it for internal web applications. The main advantage is that the developers of the "latter" classes don't need to know anything about servlets, but simply the interface with the dispatcher servlet. Also you don't have to worry about forwarding and redirecting.