louis mechery wrote:

> Hi All,
>
> My question is relevant to the servlets design issue.
> Let's say I have an application that uses several servlets.
> By default, the "Login servlet" is called.
> The "login servlet" calls a "Menu servlet" using
> sendRedirect(encodeRedirectURL("/servlet/Menu")).
> The "Menu servlet" calls other servlets using the hyperlink.
> Let's say "Search Address" or "Search Names" servlets. It is impossible to
> combine all servlets into one because of different functionalities.

Why do you feel that it is impossible?  If you take the stuff that is currently
in the doGet() or doPost() method of each of the servlets and make them a
separate method, it's not at all hard at all to combine different
functionalities into one servlet.

>
>
> 1) Are there any better design techniques?

"Better" is in the eyes of the beholder -- there are no absolutes.

One thing that a single-servlet approach lets you do is centralize things like
access control and state management (I use the same base single-servlet for all
my apps, because I'm comfortable with this pattern), but for your app a
multi-servlet approach might be just as feasible.  Sometimes a multi-servlet
approach can be easier to maintain.  To me, that is a MUCH more important issue
in the long run.

>
> 2) Any performance issues due to the fact that several servlets are called
> one after another?

Performance differences for well-designed apps will be somewhere between
neglibible and non-existent.  Why?  Well, consider how such things are
implemented.  A multi-servlet environment relies on the servlet engine to
convert a URL into a reference to a particular servlet.  A single-servlet
environment still goes through this exercize (but with fewer choices, so
presumably it takes a few less microseconds), but then goes through another
level of lookup (or a chain of "if ... else if" statements) to decide which
processing method to ultimately call.  It is highly unlikely that any
differences caused by the fact that you have one servlet versus many has any
visible impact on performance.  That's not the reason to make a choice.

>
> 3) Should I always call the servlets using encodeURL to keep the session
> active?
>

Yes.  Even if all your current users always have cookies turned on, how do you
know that will always be true?  By the way, this is true whether you choose the
single-servlet or multi-servlet approach.

Craig McClanahan

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to