Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JSP and the fly likes MVC example or tutorial Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "MVC example or tutorial" Watch "MVC example or tutorial" New topic
Author

MVC example or tutorial

hem kumar
Ranch Hand

Joined: Sep 05, 2005
Posts: 97
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....


.....For Every Problem There Is a Solution.....
Regards, Hem
hem kumar
Ranch Hand

Joined: Sep 05, 2005
Posts: 97
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

Joined: Dec 11, 2004
Posts: 13410

Bear Bibeault (a Javaranch sheriff) has written an excellent article on the subject)
http://www.javaranch.com/journal/200603/Journal200603.jsp#a5


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
hem kumar
Ranch Hand

Joined: Sep 05, 2005
Posts: 97
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

Joined: Dec 11, 2004
Posts: 13410

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

Joined: Sep 05, 2005
Posts: 97
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

Joined: Dec 11, 2004
Posts: 13410

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

Joined: Dec 11, 2004
Posts: 13410

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

Joined: Sep 05, 2005
Posts: 97
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

Joined: Nov 30, 2007
Posts: 6
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

Joined: Nov 19, 2007
Posts: 269
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

Joined: Jan 10, 2002
Posts: 60053
    
  65

"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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MVC example or tutorial
 
Similar Threads
DataClient - do we need a factory a pattern for Local / Remote mode
MVC in swing?
how MVC is implemented in Flex ?
JSP , mysql and mvc ?
MVC pattern Java Sample code.