Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JavaBeans, JSP, Classes, MVC - When To Use What Where?  RSS feed

 
Marcus Hathaway
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Being new to JSP, i'm unsure where to perform what in my web application. I'm tying to follow a simple MVC architecture. Therefore, the business end of my application (the model) is currently all processed in normal java classes. SO in theory it wouldn't make a difference if these model classes were used to process for a web application view or a normal java swing GUI view. E.g. i'm using such a class for my database source.

A servlet is acting like the conroller, taking parameters from the jsp page and then calling methods in my classes.......returning any results back to the jsp i choose.

However, i'm unsure if this is the best way to achieve things. I've seen posted how people use java beans to do stuff like connect to the database etc. Why and where would you use a java bean and how does this differ from a normal class? Is it that you can directly call the bean and set properties using EL ... so <jsp:useBean...blah blah>

I understand how to use the beans and the naming conventions etc.....but if you do this, where does that leave the servlet controller? Do you lose the controller servlet and start incorporating this into your jsp "view" page? Also.....are your model classes gonna have to be reshaped to take on bean characteristics or does the bean itself become the controller that will connect to these classes?!?

Any advice aimed at a newbe like me would be greatly appreciated?!
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check Ben Souther's this page. It has examples of MVC and other stuff. Download them and run them, they will clear many of your doubts.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!