This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
This is a tricky one to answer because in Java, unlike PHP or ASP, there's not just a single way to architect a Web application.
The general consensus is that you should use a pattern called "MVC" which stands for Model View Controller and is adopted from non-Web client-server development (and a key component of Smalltalk).
The idea being that you have a central object (a Java servlet) that manages basic application framework information such as authentication and application state objects (the model piece). It then directs application logic flow to a view component.
That sounds simple enough - but the trick is choosing a framework . And Java Web frameworks are a bit like the joke about "standards" - there's so many to choose from. It seems one can't wake up without discovering yet another new Java Web framework.
On one level they are simple to generate on your own, after all most are simply a Java servlet, that manage state in a Java bean (a Java class that just manages data and business logic) and then displays HTML (either via JSP or framework specific template files).
The 3 most popular (Based on my 'scientific' method of trolling on Javalobby, JavaRanch and TheServerSide.com plus personal experience): Apache Jakarta Struts (has the most adoption and most tools support) Apache Velocity (really a general templating engine) Apache Tapestry (cool part is that it uses standard HTML files for templates and leverages HTML attributes to do dynamic populate them)
I have a tendency to always pick Struts because I know it best. Velocity intrigues me for its simplicity.
But if I was starting from scratch - I'd go with Tapestry because I like it's use of HTML and (totally non-objective) - I'm friends with Howard Lewis Shipp who's the developer/maintainer of Tapestry .
If I were starting from scratch I wouldn't use a framework at all until I knew what went where and why. The use of a framework is not a necessity and should only be sued when you know enough to (a) know the basics of how Java web apps work , and (b) know enough to be able to decide if the use of a framework is appropriate, and if so, which one.
If you are interested in the object structure of Java web apps per se, I'd recommend grabbing a copy of the Servelts spec and read through that.