Why using Beans?

Hello,

Now, at the very beginning I'm asking what are the advantages of using beans instead on working directly with java classes (using import for example). I have an application which will use a lot of forms to access an Oracle database and I have to choose between using or not Beans. Any suggestions?

Thank you!

[349 byte] By [ddani2000] at [2007-9-26 3:29:54]
# 1

JSPs should be presentation-centric, try to keep scriptlets to a minimum (ie. <% ... %>). You'd put most/all Java code into the bean. When done properly, the JSP will consist of mostly HTML code with a few directives, declarations, expressions, scriptlets and JSP tags (ie. <jsp:usebean ... />). If you end up with lots of Java code in a JSP then I'd wonder why you are using a JSP when a servlet-only solution would do just as well.

eashanno at 2007-6-29 11:54:55 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Hi.You are correct. Instead of using <jsp:useBean/>.you can make use of our java classes directly into jsp file using import and setting classpath for that classes.but beans has additional features like scope (session, page, request, application).
v_senthilraja at 2007-6-29 11:54:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Yes, but if for example I have an application with a lot of forms and for each page in the application I have to put in the bean as many "set" and "get" as the number of forms in the page. And that's not very convenient.
ddani2000 at 2007-6-29 11:54:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

You can use regular Java objects as a bean, just avoid get/set properties. By doing this, you'll still get the scope benefits and the JSP can be presentation-centric.

If a plethora of get/set methods is your main concern, I would suggest using an IDE that creates the accessor methods for you.

eashanno at 2007-6-29 11:54:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...