• 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

Simple question

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is JavaBeans same as Servlets? Can you have all your JAvaBeans code sit in Servlets? And this way elliminate the JavaBeans?
 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JavaBeans are objects that hold data and provide "getter and setter" methods. Servlets are objects that reside on web servers and are called when requests are made. One of these cannot possibly replace the other.
 
revup triv
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually to be more specific.. I have bunch of DB calls made from JavaBeans which is nothing but simple Java methods. So my questions is why can't I put them in servlet wherever they r required & get rid of JavaBeans... what is wrong in it?
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ever heard of code reuse?
You're bound to need that same code at some other point sooner rather than later. Are you just going to copy and paste from one servlet to another?
What if you need to make a change and forget to apply it everywhere?
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
triv,
if i got u correctly, u just want to put your methods which are in beans into the servlets right.
you can do that.
but actually after MVC came into the picture, front end part in jsp, servlet as a controller and beans for methods, specially for DB calls.
you can write the methods in servlets, but better to write in beans...
it will be systematic.
what bothers you to write methods in beans??
 
He got surgery to replace his foot with a pig. He said it was because of this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic