| Author |
JavaBean or Servlet?
|
Jacket lee
Greenhorn
Joined: Oct 30, 2002
Posts: 6
|
|
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.
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12321
|
|
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
|
Java Resources at www.wbrogden.com
|
 |
Rafael Prado
Ranch Hand
Joined: May 17, 2003
Posts: 33
|
|
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?
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12321
|
|
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
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56521
|
|
5. Makes it easier to unit test. and on and on and on... Listen to William for he is wise; it's just good practice! bear [ June 04, 2003: Message edited by: Bear Bibeault ]
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
 |
|
|
subject: JavaBean or Servlet?
|
|
|