views:

39

answers:

1

I'm thinking about making a simple web application to practice custom tags, EL, ... Now I'm thinking about how to make a simple front page.

I want to have a front page where I'll show a short description of a post and then the user can click it to see the full article. Further down the line I'd like to attach a poster to it, and even further down the line I'd like to allow people to leave a comment.

Now I see two ways to do this: a) put it all into a database b) put the short description and the article into a .tag file and put the comments and users into the database.

Now I'm wondering which way would you go, or would you go for something entirely else? The first way is probably the easiest but it does require access to the database "often". The second way is a bit more "sloppy", especially depending on my implementation but it does have the advantage of accessing the database less often.

And any recommendations on keeping the data actual? I could either load everything each time somebody accesses the news page, or I could put it in the application scope and put the articles into a bean and use a listener.

And do you use hibernate/jdbc/... for a database connection?

I'm getting the feeling that the actual programming will be the easiest part.

Any directions (or book recommendations for that matter) are welcome. I've read head first servlets & jsp, and while it does a wonderful job of explaining how to develop the application I find it a bit lacking in the when/how to connect with the database and how to optimize it.

Sorry for the long post that possibly doesn't really fall under the scope of this site.

+2  A: 

As far as I can see, you are thinking too much about performance. You should not. It is of a little concern in the start. Go what feels right. Tackle performance when its actually lacking.

I would suggest you

  • You should use some pooling mechanism for database connection. Its very important and make the process very efficient. Take a look at DBCP or C3P0 or something.

  • to go store your data into the database, even the short description, in some appropriate table.

  • Moreover, don't load everything when somebody accesses the page, it might go futile and it will take a lot more time and the user gets frustrated.

  • you can cache data later when you feel its a good idea. Hibernate provide caching real easy, you might try to incorporate Hibernate, as you mentioned it yourself.

  • you can use AJAX calls wherever appropriate to get rapid request/response.

These are few things I like to mention.

Adeel Ansari
While I might be thinking a bit too much about performance, the decision will impact how I write my web app quite a bit.
I do agree, as far as you follow what we call best practices, everything would go just fine. And if you want to optimise certain thing down the road, it would be easy to do that.
Adeel Ansari