views:

507

answers:

9

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

I want to build something like twitter.

+6  A: 

Yes, definitely. Java can seem rather paralyzing with all of its frameworks; however, you can certainly build great web applications by rolling your own infrastructure. That being said, I think Spring is a great framework to look at it and is very well documented and supported.

BobbyShaftoe
+1  A: 

It is always possible to build applications, web or not, without using frameworks.

Frameworks can help you reduce the amount of code you actually write. Frameworks can be thought of as the 25% code that is common to any web application (database access, session management, access control etc) and so if you are going to write that code by your own, fine; But always keep in mind that you can reduce your work by using any of the available frameworks out there.

Frameworks give you another major advantage that they help you to design your applications in a standard way, and that helps a lot in maintaining the code.

For Java you can use Struts or Spring frameworks to build applications.

Here is a long list of Java based web application frameworks.

Niyaz
+3  A: 

Yes, it is possible. But it seldom makes sense, because you would have to implement all needed functionality from scratch by yourself. This takes a lot of time and effort and often yields worse code than you would get by using a framework. Learning a framework also takes some effort, but once you learn a framework, you can easily use the knowledge on your next project.

zoul
+2  A: 

Using regular jsp you can really just tie together a few extra classes that constitute your framework, which will normally mean some kind of servlet filter that maps a url to a class. The reason you'll often want to do this is to run some code (your controller/action) before the rendering starts.

It's all very simple ant not too far from stuff we're doing. But we're using a lot of JSTL, which is a framwork too. And some spring, yes. But a web framework is not needed.

krosenvold
+2  A: 

I suggest you look at java applications which do something like twitter. This may give you some ideas or you may just use an existing application.

http://www.google.co.uk/search?q=java+twitter

Peter Lawrey
+7  A: 
Bill the Lizard
+1 for recommending this -- it just might save me on my next project. :)
Christian Nunciato
@Christian: It definitely saved me on a project once. Of course, that was back when Struts was the only framework to speak of. :)
Bill the Lizard
+6  A: 

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.

duffymo
A: 

I would go with Spring MVC 2.5+ using annotations. Very simple.

bpapa
+1  A: 

Yes, absolutely. Go ahead, and don't let anyone discourage you! Back in the day, the first solo-flight project a new java programmer would write would be something to suck porn from thehun.com . I applaud the maturity of our young programmers these days.

paulmurray