my dog learned polymorphism
The moose likes JSP and the fly likes Implementation of discussion forum Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Implementation of discussion forum" Watch "Implementation of discussion forum" New topic

Implementation of discussion forum

Kalyan Anand
Ranch Hand

Joined: Feb 07, 2007
Posts: 194
I want to develop a discussion forum ... similar to javaranch...for learing experience. please suggest what i should use in which layer... i know that the basic mvc must be followed but should i access the database from jsp using some taglibs or i better access db using servlets ?

any hints on getting started will be quite useful.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63857

Neither. In a properly structured web application, DB access occurs in the model classes, none of which should have any knowledge of the presentation and controller layers.

[Asking smart questions] [About Bear] [Books by Bear]
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33113

I'd like to suggesting looking at existing open source software - for example JForum 3. They follow MVC properly so you could see how they do it.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
David Newton

Joined: Sep 29, 2008
Posts: 12617

I access the DB from services (at least when using Java) :p

It's often more instructive to make your own decisions, and once you realize your mistakes, go back in and fix them. Repeat these steps frequently, and eventually you come to understand whatever frameworks and methodologies you're using.

For example, you might start out by using plain servlets and JSPs. Once you have some application functionality you're happy with, you might ask "Here's an example servlet in my forum application; how can I make it better?" Then somebody would say "Oh, use services to handle the database access." So you move your database code into services, and ask "How can I make this better?" Somebody might say "If you inject your services into your servlets it makes testing much easier."

You reply "Testing?!" and create a suite of unit tests and begin injecting the services. Then somebody says "Why aren't you using Spring to do your database work? It's so much easier." Then you use Spring to handle your JDBC (if you're not using an ORM). Along the way to discover that Spring can be used to handle some other functionality you're looking at, including replacing servlets with Spring MVC. Or you might decide that something like Wicket fits the way you think better--or Struts, or Frontman, or Tapestry, or Stripes, or JSF (ew!), or whatever, and re-implement servlets using your new favorite technology.

This goes on forever.
I agree. Here's the link:
subject: Implementation of discussion forum
It's not a secret anymore!