简体   繁体   中英

How to develop good JSP/Servlet WebApplication with NetBeans

What if I need to develop a web application in Java with a database? I know that I need to develop first the bean so I have to create a class for every database's table and a field for every database's columns, setter, getter, no arguments constructor and so on.

Now:

What if I need to save a record inside the database? Suppose to have PersonBean class and PersonController I do:

PersonBean p = new PersonBean();
p.setName("Mariano");
....
PersonController c = new PersonController();
c.insert(p);

It's legal? It's elegant. This is coherent with a high-level abstraction?

I think you should look over the ORM-frameworks like Hibernate. It (edit: not "it" but NetBeans IDE ) can automatically generate JavaBeans for your database, and vice versa. It also contains most of the functionality you need to create-read-update-delete operations. It's free and can save you a huge amount of time.

EDIT: And for the output you could use JSF for example or Spring framework (which also includes Hibernate support).

I'm not a pro-J2EE developer so I can be wrong in something, but that's the way I see it.

This is not necessarily a netbeans question, though netbeans will have some tools to examine your db and create objects and vice-versa. The question here is really what framework you want to develop your app in. You could try Spring Roo if you want alot of convention based coding. IE, you create a java object, and the framework figures out your table names and column names based on how you've named your objects and properties.

It would also make URL's accessible based on your object names, etc....

Think of it as a Ruby on Rails for java. There's also grails which is very similar but uses the "Groovy" language, which is essentially java, but with a bunch of extensions.

Both Grails and Roo will run on any servlet container (ie, tomcat, jetty, weblogic, etc...)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM