File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes OOP in web development Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "OOP in web development" Watch "OOP in web development" New topic

OOP in web development

Juhan Voolaid
Ranch Hand

Joined: Nov 18, 2003
Posts: 179

This is maybe offtopic here, because i don't want to talk about jsp. I use php, but i think they are quite similar.

I know the basics of object oriented programming but what i want to know is how and where to use OOP in web development.

Can someone describe me a simple class diagram of a web project - its variables, methods and the description of this object itself.

Mark Wilcox

Joined: Sep 01, 2004
Posts: 6
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 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 .

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63844

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.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: OOP in web development
It's not a secret anymore!