aspose file tools*
The moose likes Servlets and the fly likes Simple question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Simple question" Watch "Simple question" New topic
Author

Simple question

revup triv
Greenhorn

Joined: Aug 17, 2003
Posts: 27
Is JavaBeans same as Servlets? Can you have all your JAvaBeans code sit in Servlets? And this way elliminate the JavaBeans?
Anthony Watson
Ranch Hand

Joined: Sep 25, 2003
Posts: 327
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.


Anthony W.<br />MCP, SCJP 1.4, SCJD, SCWCD 1.3, SCWCD 1.4, SCBCD
revup triv
Greenhorn

Joined: Aug 17, 2003
Posts: 27
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?
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
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?


42
m bhramaresh
Greenhorn

Joined: Jan 09, 2004
Posts: 13
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??
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple question