Who can answer my question? 1.When is the best time to use JavaBean not Servlet? 2.When is the best time to use Servlet not JavaBean? 3.You can use Jsp to solve the question,why you also need to use Servlet? Thanks first.
1 & 2 Good design says your servlet should handle the communication interface and you should use JavaBeans (or other helper classes) to handle complex computing tasks, database lookup, etc. - In other words, don't try to do it all in one servlet class. 3. For one thing, you have to use servlet when working with binary data. Typically a servlet is the entry point for requests that may eventually be redirected to a JSP. JSP should not be loaded down with Java computations. Bill
Originally posted by William Brogden: In other words, don't try to do it all in one servlet class.
Is it only for modularity purposes, or are there other aspects relevants of this statement?
Author and all-around good cowpoke
Joined: Mar 22, 2000
Reasons for using JavaBeans or other helper class: 1. You can debug the helper class outside the servlet container environment, thus saving time and frustation due to having to repeatedly reload the servlet. 2. Makes it easier to avoid Thread conflict problems. 3. Makers it easier to maintain and to explain to other programmers. 4. With good design, the helper class may prove useful in other projects. Bill