Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MVC example or tutorial

 
hem kumar
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all...can anybody please referer me any site or resource containing good mvc examples or tutorials in java environment. What i partiuclary want is......

"Model-->implemented in Java Beans.....View--> implemented in Jsp and Controller--> implemented in servlet....and Database in mysql or something like that.....

All the help will be appreciated......Thank you....
 
hem kumar
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My requirement is that the user should input some data like a online registration form, then those things should be validated(optional) and then it should go to the database...and in the next page those things should be retrieved from the database and displayed to the user....
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault (a Javaranch sheriff) has written an excellent article on the subject)
http://www.javaranch.com/journal/200603/Journal200603.jsp#a5
 
hem kumar
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ben....i have gone through the article mentioned by you....It also cleared some confusion regarding mvc pattern...But i need some code which can help me learn it properly.....
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My own site http://simple.souther.us has lots of sample servlet code.
Almost all of the examples use MVC.
None of them, however, actually access a JDBC database.
 
hem kumar
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ben...i went through your simpleMvc program from your site....its a good starting point....but after capturing the values in javabeans how can it be inserted to a database and again retrieved from it and displayed in a separate jsp? can you please give any ideas or hints regarding this ?? I need these things desparetely...Thank you....
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do have one other example up there that I haven't really published.
http://simple.souther.us/SimpleTable.war
It was mostly a draft so don't mind the mess.

It uses a mock resultSet to show one way of removing the data from the it to make it available to a scriptless JSP.

At some point, I'd like to see if I can re-write it using an embedded relational database like HSQL.

If you play with it, the thing to notice is that the AddressBook class doesn't rely on anything in the javax.servlet.* package. For that reason, it can be called from the command line and would be usable from a Servlet, Swing, command line, or any other type of application regardless of its user interface.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of the reasons that you probably don't see too many examples that try to tie this all together is that MVC and DAO (Data Access Objects) are both designed to insure that the various layers of an enterprise web application don't rely on one another.

A good DAO layer insures that the person working on the web side has no idea what kind of database is being used (or if one is even being used).
Likewise the proper use of MVC insures that web specific APIs don't bleed into the business layers of the application.
 
hem kumar
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ben..i went through all of your examples.....and after reading your reply...i am planning to move into struts directly.....Thank you..
 
lohith mk
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Anand,
if you are trying to do some struts application better you got to java boutique website is really good.
the url is http://javaboutique.internet.com/
or you can go for roseindia.com
 
Bryce Martin
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Mohan,

I would argue against going to struts. I've just recently adopted MVC into my project I'm working on. Before I was doing a JSP code mash with all kinds of stuff in it. I too had a hard time finding examples of code that connected directly to a database, in fact I don't think I found any at all. But I have pulled my code apart and put it into the MVC model, with DB connections, result set processing into beans via servlets, and displaying the information in a table in my jsp using JSTL and EL. It works wonderfully and it is slightly faster than doing it my old way. If you want an example of some code just reply back here.

Thanks
Bryce Martin
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64824
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"lohith mk",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic