• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP to Database linking

 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been thinking of creating a basic message board. I figure the best way to go about this is to use jsp, servlets and a database on the backend. To create new messages, I would imagine the way to go about this is to use an html form and then have the servlet enter it into the database. My question is this: after I display the topics from the database, how do I link the posted messages to the database? I can't use a simple <a href tag right?
Any input would be appreciated. ( I wasn't sure if this should go here or in jdbc)
- Sean
 
Julia Reynolds
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the Jive message board. It is opensource, so you can look at the source code:
http://www.jivesoftware.com/
Julia
 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for the reply. I had already checked out jive, it is very impressive. But it's tough to wade through all the source code and identifying what I'm looking for. My question is a lot simpler: How would I put a link on a jsp page that retrieves the contents from a record in a database?
 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay I've been thinking about this some more. If I had a subject in a forum entitled:
Java
How would I link to a database that contains a record of the contents of that post? Should I link that topic to a servlet and have the servlet retrieve the record and then display it in a page? Is this the right approach? Any thoughts would be appreciated.
Thanks,
Sean
 
Marcos Maia
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think a better approach is to build a class that is a pool of connections than you should build a Java Bean to store the resultSets and do a class to connect to the DB using your connection pool and store the results in the bean and then u can easily show this results using a jsp page, and your servlet will be used only like a controller to these actions.
 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been reading up on this, and I fully agree with you. I think I should use the Jsp as the view, servlet as the controller and the beans as the model. However, I still don't understand how to display the messages.

Thanks for your reply,

Sean
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!