• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JavaBean or Servlet?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Die Fledermaus does not fear such a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic