Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to build a Java web application without using a framework?

If not what is a good friendly java framework for newcomers?

I want to build something like twitter.

like image 783
user62617 Avatar asked Feb 14 '09 07:02

user62617


1 Answers

You can go a very long way with just servlets and JDBC. Consider JSPs using JSTL as an added nicety.

But I'd bet that if your web site consists of more than a page or two delivering database content to the browser, you'll quickly discover why web frameworks are so numerous. Hard-wired page navigation, control logic, blurred layers, etc. will cause headaches as your site grows.

You'll find you have a lot of similar, repetitive, but slightly different code for each bit of new functionality. If you have to maintain a site and keep it going, eventually it's likely that you'll reach the conclusion that there are patterns ripe for capturing. Who knows? Maybe you'll decide as a result of your experience that you want to take a crack at solving the web framework problem, too.

Whatever you do, I think having distinct layers is key. Don't have servlets do all the work - they're for handling HTTP requests. Embed the work in service classes that your servlets can simply call. That way you can reuse that logic. Keep persistence code in its own layer and don't let it leak out into others. You can have reusable components that will survive your first efforts. If you decide to switch to a web framework you'll just snap these layers into place and off you go.

I wrote my first significant web site without any frameworks - just straight servlets, JSPs and JDBC. It gave me a better understanding of what was going on. I think it helps.

like image 52
duffymo Avatar answered Sep 19 '22 18:09

duffymo