Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

MVC example or tutorial

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67650
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic