Jon Wilmoth wrote:

> Two questions:
>
> 1) I was interested in knowing if anyone had any performance
> problems/insight when using the following architecture:
> All jsp's submit to one servlet which dispatches requests to the appropriate
> jsp.
>

As long as you're using RequestDispatcher.forward() instead of sendRedirect() to
do your dispatching, the performance should be basically indistinguishable from
submitting to the JSP page directly -- but you get MUCH cleaner code doing it as
you propose.  Basically, all the servlet container has to do a glorified hashtable
lookup (to get the instance of the JSP page you're forwarding to) and then calls
the service() method.

>
> 2) Of the various ways to include responses from other servlets(jsps),
> forward, redirect are there preferred methods (ie Using a StringBuffer for
> repeated string concatenations vs. string + string + string)?
>

Yes, using StringBuffer instead of string + string + string runs faster.  The
question is, really, does it matter?  I've trained myself to use StringBuffer when
I'm accumulating results the first time I write the code, but in reality the
compute-time cost of doing the concatenations usually gets dwarfed by the network
and database overheads of web applications.

Like everything in life, there are tradeoffs to consider.  Focusing on low-level
code optimizations too early usually delays your initial delivery (which is often
a high priority goal).  IMHO you should spend time early in your project on a
clean architectural design that is flexible (in terms of being able to incorporate
future changes) to the maximum degree you can predict.  If you run into
performance hot spots, optimize those later.

>
> --
> Thanks,
> Jon Wilmoth
>

Craig McClanahan

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to