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